Skip to content

Commit b54f2c0

Browse files
author
Auke Booij
authored
Merge branch 'master' into 4547-introspection-reuse-variables
2 parents 4accd95 + 6069cc9 commit b54f2c0

File tree

9 files changed

+446
-66
lines changed

9 files changed

+446
-66
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ Read more about the session argument for computed fields in the [docs](https://h
6666
- cli: list all available commands in root command help (fix #4623)
6767
- docs: add section on actions vs. remote schemas to actions documentation (#4284)
6868
- docs: fix wrong info about excluding scheme in CORS config (#4685)
69+
- docs: add single object mutations docs (close #4622) (#4625)
6970
- docs: add docs page on query performance (close #2316) (#3693)
7071
- docs: add a sample Caddyfile for Caddy 2 in enable-https section (#4710)
7172

docs/graphql/manual/api-reference/graphql-api/mutation.rst

Lines changed: 154 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ API Reference - Mutation
1111
:backlinks: none
1212
:depth: 2
1313
:local:
14-
14+
1515
.. _insert_upsert_syntax:
1616

17-
Insert / upsert syntax
18-
----------------------
17+
**insert** (upsert) syntax
18+
--------------------------
1919

2020
.. code-block:: none
2121
@@ -99,8 +99,8 @@ Insert / upsert syntax
9999
100100
.. _insert_upsert_one_syntax:
101101

102-
Insert / upsert one syntax
103-
--------------------------
102+
**insert_one** syntax
103+
---------------------
104104

105105
.. code-block:: none
106106
@@ -157,11 +157,89 @@ Insert / upsert one syntax
157157
}
158158
}
159159
160+
.. _update_by_pk_syntax:
161+
162+
**update_by_pk** syntax
163+
-----------------------
164+
165+
.. code-block:: none
166+
167+
mutation [<mutation-name>] {
168+
<mutation-field-name> (
169+
[pk-columns-argument!],
170+
[set-argument!]
171+
)
172+
<object-fields>
173+
}
174+
175+
.. list-table::
176+
:header-rows: 1
177+
178+
* - Key
179+
- Required
180+
- Schema
181+
- Description
182+
* - mutation-name
183+
- false
184+
- Value
185+
- Name of mutation for observability
186+
* - mutation-field-name
187+
- true
188+
- Value
189+
- Name of the auto-generated update mutation field, e.g. *update_author_by_pk*
190+
* - pk-columns-argument
191+
- true
192+
- pkColumnsArgExp_
193+
- Primary key(s) for row(s) to be updated
194+
* - set-argument
195+
- false
196+
- setArgExp_
197+
- Data to be updated in the table
198+
* - inc-argument
199+
- false
200+
- incArgExp_
201+
- Integer value to be incremented to Int columns in the table
202+
* - append-argument
203+
- false
204+
- appendArgExp_
205+
- JSON value to be appended to JSONB columns in the table
206+
* - prepend-argument
207+
- false
208+
- prependArgExp_
209+
- JSON value to be prepended to JSONB columns in the table
210+
* - delete-key-argument
211+
- false
212+
- deleteKeyArgExp_
213+
- Key to be deleted in the value of JSONB columns in the table
214+
* - delete-elem-argument
215+
- false
216+
- deleteElemArgExp_
217+
- Array element to be deleted in the value of JSONB columns in the table
218+
* - delete-at-path-argument
219+
- false
220+
- deleteAtPathArgExp_
221+
- Element at path to be deleted in the value of JSONB columns in the table
222+
223+
**E.g. UPDATE BY PK**:
224+
225+
.. code-block:: graphql
226+
227+
mutation update_articles {
228+
update_article_by_pk (
229+
pk_columns: {
230+
id: 1
231+
}
232+
_set: { is_published: true }
233+
) {
234+
id
235+
title
236+
}
237+
}
160238
161239
.. _update_syntax:
162240

163-
Update syntax
164-
-------------
241+
**update** syntax
242+
-----------------
165243

166244
.. code-block:: none
167245
@@ -238,10 +316,54 @@ Update syntax
238316
}
239317
}
240318
319+
.. _delete_by_pk_syntax:
320+
321+
**delete_by_pk** syntax
322+
-----------------------
323+
324+
.. code-block:: none
325+
326+
mutation [<mutation-name>] {
327+
<mutation-field-name> (
328+
column1: value1
329+
column2: value2
330+
)
331+
<object-fields>
332+
}
333+
334+
.. list-table::
335+
:header-rows: 1
336+
337+
* - Key
338+
- Required
339+
- Schema
340+
- Description
341+
* - mutation-name
342+
- false
343+
- Value
344+
- Name of mutation for observability
345+
* - mutation-field-name
346+
- true
347+
- Value
348+
- Name of the auto-generated delete mutation field, e.g. *delete_author_by_pk*
349+
350+
**E.g. DELETE BY PK**:
351+
352+
.. code-block:: graphql
353+
354+
mutation delete_articles {
355+
delete_article_by_pk (
356+
id: 1
357+
) {
358+
id
359+
title
360+
}
361+
}
362+
241363
.. _delete_syntax:
242364

243-
Delete syntax
244-
-------------
365+
**delete** syntax
366+
-----------------
245367

246368
.. code-block:: none
247369
@@ -431,6 +553,29 @@ E.g.:
431553
where: {id: {_lt: 1}}
432554
}
433555
556+
.. _pkColumnsArgExp:
557+
558+
**pk_columns** argument
559+
^^^^^^^^^^^^^^^^^^^^^^^
560+
561+
The ``pk_columns`` argument is used to identify an object by its primary key columns in *update* mutations.
562+
563+
.. code-block:: none
564+
565+
pk_columns: {
566+
column-1: value-1
567+
column-2: value-2
568+
}
569+
570+
E.g.:
571+
572+
.. code-block:: graphql
573+
574+
pk_columns: {
575+
id: 1
576+
name: "Harry"
577+
}
578+
434579
.. _whereArgExp:
435580

436581
**where** argument

docs/graphql/manual/api-reference/graphql-api/query.rst

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ API Reference - Query / Subscription
1212
:depth: 3
1313
:local:
1414

15-
Query / subscription syntax
16-
---------------------------
15+
**query** / **subscription** syntax
16+
-----------------------------------
1717

1818
.. code-block:: none
1919
@@ -69,6 +69,57 @@ Query / subscription syntax
6969

7070
For more examples and details of usage, please see :ref:`this <queries>`.
7171

72+
**query_by_pk** / **subscription_by_pk** syntax
73+
-----------------------------------------------
74+
75+
.. code-block:: none
76+
77+
query|subscription [<op-name>] {
78+
<query-field-name> (
79+
column1: value1
80+
column2: value2
81+
)
82+
<object-fields>
83+
}
84+
85+
.. list-table::
86+
:header-rows: 1
87+
88+
* - Key
89+
- Required
90+
- Schema
91+
- Description
92+
* - op-name
93+
- false
94+
- Value
95+
- Name query/subscription for observability
96+
* - query-field-name
97+
- true
98+
- Value
99+
- Name of the auto-generated query field, e.g. *article_by_pk*
100+
101+
**E.g. QUERY BY PK**:
102+
103+
.. code-block:: graphql
104+
105+
query {
106+
article_by_pk(id: 1) {
107+
id
108+
title
109+
}
110+
}
111+
112+
**E.g. SUBSCRIPTION BY PK**:
113+
114+
.. code-block:: graphql
115+
116+
subscription {
117+
article_by_pk(id: 1) {
118+
id
119+
title
120+
}
121+
}
122+
72123
Syntax definitions
73124
------------------
74125

docs/graphql/manual/api-reference/schema-metadata-api/table-view.rst

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,11 @@ Add a table/view ``author``:
133133
"select_by_pk": "Author",
134134
"select_aggregate": "AuthorAggregate",
135135
"insert": "AddAuthors",
136+
"insert_one":"AddAuthor",
136137
"update": "UpdateAuthors",
137-
"delete": "DeleteAuthors"
138+
"update_by_pk": "UpdateAuthor",
139+
"delete": "DeleteAuthors",
140+
"delete_by_pk": "DeleteAuthor"
138141
},
139142
"custom_column_names": {
140143
"id": "authorId"
@@ -199,28 +202,40 @@ Custom Root Fields
199202
- Description
200203
* - select
201204
- false
202-
- `String`
205+
- ``String``
203206
- Customise the ``<table-name>`` root field
204207
* - select_by_pk
205208
- false
206-
- `String`
209+
- ``String``
207210
- Customise the ``<table-name>_by_pk`` root field
208211
* - select_aggregate
209212
- false
210-
- `String`
213+
- ``String``
211214
- Customise the ``<table-name>_aggregete`` root field
212215
* - insert
213216
- false
214-
- `String`
217+
- ``String``
215218
- Customise the ``insert_<table-name>`` root field
219+
* - insert_one
220+
- false
221+
- ``String``
222+
- Customise the ``insert_<table-name>_one`` root field
216223
* - update
217224
- false
218-
- `String`
225+
- ``String``
219226
- Customise the ``update_<table-name>`` root field
227+
* - update_by_pk
228+
- false
229+
- ``String``
230+
- Customise the ``update_<table-name>_by_pk`` root field
220231
* - delete
221232
- false
222-
- `String`
233+
- ``String``
223234
- Customise the ``delete_<table-name>`` root field
235+
* - delete_by_pk
236+
- false
237+
- ``String``
238+
- Customise the ``delete_<table-name>_by_pk`` root field
224239

225240
.. _set_table_custom_fields:
226241

@@ -249,8 +264,11 @@ Set custom fields for table/view ``author``:
249264
"select_by_pk": "Author",
250265
"select_aggregate": "AuthorAggregate",
251266
"insert": "AddAuthors",
267+
"insert_one":"AddAuthor",
252268
"update": "UpdateAuthors",
253-
"delete": "DeleteAuthors"
269+
"update_by_pk": "UpdateAuthor",
270+
"delete": "DeleteAuthors",
271+
"delete_by_pk": "DeleteAuthor"
254272
},
255273
"custom_column_names": {
256274
"id": "authorId"

0 commit comments

Comments
 (0)