graphql-engine/docs/graphql/manual/mutations/index.rst

48 lines
1.0 KiB
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Mutations
=========
GraphQL mutations are used to modify server-side data (i.e. write, update or delete data). As with queries, mutation
fields are auto-generated based on the Postgres schema. Heres a sample mutation field from our reference
author/article schema:
.. code-block:: graphql
insert_article (
objects: [article_insert_input!]!
on_conflict: article_on_conflict
): article_mutation_response
# response of any mutation on the table "article"
type article_mutation_response {
# number of affected rows by the mutation
affected_rows: Int!
#data of the affected rows by the mutation
returning: [author!]!
}
As you can see from the schema, you can:
#. Pass multiple objects to the mutation.
#. Return objects (with nested objects) from the affected rows in the response.
Let's use this reference author/article schema to look at different types of mutations.
.. toctree::
:maxdepth: 1
Insert <insert>
Upsert <upsert>
Update <update>
Delete <delete>
multiple-mutations