A plugin for Graphile to generate upsert mutations.
npm install graphile-upsert-pluginupsert${Table}) using postgres INSERT INTO ON CONFLICT UPDATE statements. It includes:index.js (original)--append-plugins graphile-upsert-pluginbatch.js, which accepts a non-empty list of records--append-plugins graphile-upsert-plugin/batchbatch-allow-empty.js which is the same but with empty values allowed--append-plugins graphile-upsert-plugin/batch-allow-empty
If you add both via --append-plugins graphile-upsert-plugin,graphile-upsert-plugin/batch, your schema should look something like:
``graphqlEvent
"""All input for the upsert batch mutation."""...
input UpsertEventBatchInput {
clientMutationId: String
"""
The Events to be upserted by this mutation. Expects all records to conform to the structure of the first.
"""
events: [EventInput!]!
}
type Mutation {
# ...
"""Upserts a single Event."""
upsertEvent(
"""
The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields.
"""
input: UpsertEventInput!
): UpsertEventPayload
"""Upserts a batch of Events."""
upsertEventBatch(
"""
The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields.
"""
input: UpsertEventBatchInput!
): UpsertEventBatchPayload
# ...
}