diff --git a/docs/graphql/manual/mutations/upsert.rst b/docs/graphql/manual/mutations/upsert.rst index c1dbc7963d5..fd15a8c5460 100644 --- a/docs/graphql/manual/mutations/upsert.rst +++ b/docs/graphql/manual/mutations/upsert.rst @@ -33,44 +33,53 @@ upsert request in case of conflicts. Update selected columns on conflict ----------------------------------- -Insert a new object in the author table or, if the primary key constraint, ``author_pkey``, is violated, update the columns -specified in ``update_columns``: +Insert a new object in the ``article`` table or, if the primary key constraint, ``article_pkey``, is violated, update +the columns specified in ``update_columns``: .. graphiql:: :view_only: :query: - mutation upsert_author { - insert_author( + mutation upsert_article { + insert_article ( objects: [ - {name: "John", id: 10} + { + id: 2, + title: "ex quis mattis", + content: "Pellentesque lobortis quam non leo faucibus efficitur", + published_on: "2018-10-12" + } ], on_conflict: { - constraint: author_pkey, - update_columns: [name] + constraint: article_pkey, + update_columns: [title, content] } ) { - affected_rows - returning{ + returning { id - name + title + content + published_on } } } :response: { "data": { - "insert_author": { - "affected_rows": 1, + "insert_article": { "returning": [ - { - "name": "John", - "id": 10 - } - ] + { + "id": 2, + "title": "ex quis mattis", + "content": "Pellentesque lobortis quam non leo faucibus efficitur", + "published_on": "2018-06-10" + } + ] } } } +The ``published_on`` column is left unchanged as it wasn't present in ``update_columns``. + Ignore request on conflict -------------------------- If ``update_columns`` is an **empty array** then GraphQL Engine ignore changes on conflict. Insert a new object into @@ -101,7 +110,7 @@ the author table or, if the unique constraint, ``author_name_key``, is violated, } } -In this case, the insert mutation is ignored because there is a conflict. +In this case, the insert mutation is ignored because there is a conflict and ``update_columns`` is empty. Upsert in nested mutations