@@ -18,7 +18,7 @@ A GraphQL service generates a response from a request via execution.
18
18
- {extensions} (optional): A map reserved for implementation-specific additional
19
19
information.
20
20
21
- Given this information, the result of {ExecuteRequest (schema, document,
21
+ Given this information, the result of {Request (schema, document,
22
22
operationName, variableValues, initialValue)} produces the response, to be
23
23
formatted according to the Response section below.
24
24
@@ -39,27 +39,45 @@ and have no effect on the observable execution, validation, or response of a
39
39
GraphQL document. Descriptions and comments on executable documents MAY be used
40
40
for non-observable purposes, such as logging and other developer tools.
41
41
42
- ## Executing Requests
42
+ ## Processing Requests
43
43
44
- To execute a request, the executor must have a parsed {Document} and a selected
44
+ <a name =" #sec-Executing-Requests " >
45
+ <!-- Legacy link, this section was previously titled "Executing Requests" -->
46
+ </a >
47
+
48
+ To process a request, the executor must have a parsed {Document} and a selected
45
49
operation name to run if the document defines multiple operations, otherwise the
46
50
document is expected to only contain a single operation. The result of the
47
- request is determined by the result of executing this operation according to the
48
- "Executing Operations” section below.
51
+ request is determined by the result of performing this operation according to
52
+ the "Performing Operations” section below.
53
+
54
+ The {Request()} algorithm contains the preamble for _ execution_ , handling
55
+ concerns such as determining the operation and coercing the inputs, before
56
+ passing the request on to the relevant algorithm for the operation's type which
57
+ then performs any other necessary preliminary steps (for example establishing
58
+ the source event stream for subscription operations) and then initiates
59
+ _ execution_ .
60
+
61
+ Note: An error raised before _ execution_ begins will typically be a _ request
62
+ error_ , and once _ execution_ begins will typically be an _ execution error_ .
49
63
50
- ExecuteRequest(schema, document, operationName, variableValues, initialValue):
64
+ :: We define _ execution_ as the process of executing the operation's _ root
65
+ selection set_ through {ExecuteRootSelectionSet()}, and hence _ execution_ begins
66
+ when {ExecuteRootSelectionSet()} is called for the first time in a request.
67
+
68
+ Request(schema, document, operationName, variableValues, initialValue):
51
69
52
70
- Let {operation} be the result of {GetOperation(document, operationName)}.
53
71
- Let {coercedVariableValues} be the result of {CoerceVariableValues(schema,
54
72
operation, variableValues)}.
55
73
- If {operation} is a query operation:
56
- - Return {ExecuteQuery (operation, schema, coercedVariableValues,
74
+ - Return {Query (operation, schema, coercedVariableValues,
57
75
initialValue)}.
58
76
- Otherwise if {operation} is a mutation operation:
59
- - Return {ExecuteMutation (operation, schema, coercedVariableValues,
77
+ - Return {Mutation (operation, schema, coercedVariableValues,
60
78
initialValue)}.
61
79
- Otherwise if {operation} is a subscription operation:
62
- - Return {Subscribe (operation, schema, coercedVariableValues, initialValue)}.
80
+ - Return {Subscription (operation, schema, coercedVariableValues, initialValue)}.
63
81
64
82
GetOperation(document, operationName):
65
83
@@ -74,27 +92,28 @@ GetOperation(document, operationName):
74
92
75
93
### Validating Requests
76
94
77
- As explained in the Validation section, only requests which pass all validation
78
- rules should be executed. If validation errors are known, they should be
79
- reported in the list of "errors" in the response and the request must fail
80
- without execution.
95
+ As explained in the Validation section, only operations from documents which
96
+ pass all validation rules should be executed. If validation errors are known,
97
+ they should be reported in the list of "errors" in the response and the request
98
+ must fail without execution.
81
99
82
100
Typically validation is performed in the context of a request immediately before
83
- execution, however a GraphQL service may execute a request without immediately
84
- validating it if that exact same request is known to have been validated before.
85
- A GraphQL service should only execute requests which _ at some point_ were known
86
- to be free of any validation errors, and have since not changed.
101
+ calling {Request()}, however a GraphQL service may process a request without
102
+ immediately validating the document if that exact same document is known to have
103
+ been validated before. A GraphQL service should only execute operations which
104
+ _ at some point_ were known to be free of any validation errors, and have since
105
+ not changed.
87
106
88
- For example: the request may be validated during development, provided it does
89
- not later change, or a service may validate a request once and memoize the
90
- result to avoid validating the same request again in the future.
107
+ For example: the document may be validated during development, provided it does
108
+ not later change, or a service may validate a document once and memoize the
109
+ result to avoid validating the same document again in the future.
91
110
92
111
### Coercing Variable Values
93
112
94
113
If the operation has defined any variables, then the values for those variables
95
114
need to be coerced using the input coercion rules of variable's declared type.
96
115
If a _ request error_ is encountered during input coercion of variable values,
97
- then the operation fails without execution .
116
+ then the request fails without _ execution _ .
98
117
99
118
CoerceVariableValues(schema, operation, variableValues):
100
119
@@ -131,7 +150,11 @@ CoerceVariableValues(schema, operation, variableValues):
131
150
132
151
Note: This algorithm is very similar to {CoerceArgumentValues()}.
133
152
134
- ## Executing Operations
153
+ ## Performing Operations
154
+
155
+ <a name =" #sec-Executing-Operations " >
156
+ <!-- Legacy link, this section was previously titled "Executing Operations" -->
157
+ </a >
135
158
136
159
The type system, as described in the "Type System" section of the spec, must
137
160
provide a query root operation type. If mutations or subscriptions are
@@ -144,9 +167,9 @@ If the operation is a query, the result of the operation is the result of
144
167
executing the operation’s _ root selection set_ with the query root operation
145
168
type.
146
169
147
- An initial value may be provided when executing a query operation.
170
+ An initial value may be provided when perfoming a query operation.
148
171
149
- ExecuteQuery (query, schema, variableValues, initialValue):
172
+ Query (query, schema, variableValues, initialValue):
150
173
151
174
- Let {queryType} be the root Query type in {schema}.
152
175
- Assert: {queryType} is an Object type.
@@ -164,7 +187,7 @@ It is expected that the top level fields in a mutation operation perform
164
187
side-effects on the underlying data system. Serial execution of the provided
165
188
mutations ensures against race conditions during these side-effects.
166
189
167
- ExecuteMutation (mutation, schema, variableValues, initialValue):
190
+ Mutation (mutation, schema, variableValues, initialValue):
168
191
169
192
- Let {mutationType} be the root Mutation type in {schema}.
170
193
- Assert: {mutationType} is an Object type.
@@ -176,12 +199,13 @@ ExecuteMutation(mutation, schema, variableValues, initialValue):
176
199
177
200
If the operation is a subscription, the result is an _ event stream_ called the
178
201
_ response stream_ where each event in the event stream is the result of
179
- executing the operation for each new event on an underlying _ source stream_ .
202
+ executing the operation’s _ root selection set_ for each new event on an
203
+ underlying _ source stream_ .
180
204
181
- Executing a subscription operation creates a persistent function on the service
205
+ Perfoming a subscription operation creates a persistent function on the service
182
206
that maps an underlying _ source stream_ to a returned _ response stream_ .
183
207
184
- Subscribe (subscription, schema, variableValues, initialValue):
208
+ Subscription (subscription, schema, variableValues, initialValue):
185
209
186
210
- Let {sourceStream} be the result of running
187
211
{CreateSourceEventStream(subscription, schema, variableValues, initialValue)}.
@@ -190,8 +214,8 @@ Subscribe(subscription, schema, variableValues, initialValue):
190
214
variableValues)}.
191
215
- Return {responseStream}.
192
216
193
- Note: In a large-scale subscription system, the {Subscribe ()} and
194
- {ExecuteSubscriptionEvent ()} algorithms may be run on separate services to
217
+ Note: In a large-scale subscription system, the {Subscription ()} and
218
+ {SubscriptionEvent ()} algorithms may be run on separate services to
195
219
maintain predictable scaling properties. See the section below on Supporting
196
220
Subscriptions at Scale.
197
221
@@ -313,7 +337,7 @@ MapSourceToResponseEvent(sourceStream, subscription, schema, variableValues):
313
337
- Let {responseStream} be a new _ event stream_ .
314
338
- When {sourceStream} emits {sourceValue}:
315
339
- Let {executionResult} be the result of running
316
- {ExecuteSubscriptionEvent (subscription, schema, variableValues,
340
+ {SubscriptionEvent (subscription, schema, variableValues,
317
341
sourceValue)}.
318
342
- If internal {error} was raised:
319
343
- Cancel {sourceStream}.
@@ -328,21 +352,21 @@ MapSourceToResponseEvent(sourceStream, subscription, schema, variableValues):
328
352
- Complete {responseStream} normally.
329
353
- Return {responseStream}.
330
354
331
- Note: Since {ExecuteSubscriptionEvent ()} handles all _ execution error_ , and
355
+ Note: Since {SubscriptionEvent ()} handles all _ execution error_ , and
332
356
_ request error_ only occur during {CreateSourceEventStream()}, the only
333
- remaining error condition handled from {ExecuteSubscriptionEvent ()} are internal
357
+ remaining error condition handled from {SubscriptionEvent ()} are internal
334
358
exceptional errors not described by this specification.
335
359
336
- ExecuteSubscriptionEvent (subscription, schema, variableValues, initialValue):
360
+ SubscriptionEvent (subscription, schema, variableValues, initialValue):
337
361
338
362
- Let {subscriptionType} be the root Subscription type in {schema}.
339
363
- Assert: {subscriptionType} is an Object type.
340
364
- Let {rootSelectionSet} be the _ root selection set_ in {subscription}.
341
365
- Return {ExecuteRootSelectionSet(variableValues, initialValue,
342
366
subscriptionType, rootSelectionSet, "normal")}.
343
367
344
- Note: The {ExecuteSubscriptionEvent ()} algorithm is intentionally similar to
345
- {ExecuteQuery ()} since this is how each event result is produced.
368
+ Note: The {SubscriptionEvent ()} algorithm is intentionally similar to
369
+ {Query ()} since this is how each event result is produced.
346
370
347
371
#### Unsubscribe
348
372
@@ -638,7 +662,7 @@ A valid GraphQL executor can resolve the four fields in whatever order it chose
638
662
(however of course ` birthday ` must be resolved before ` month ` , and ` address `
639
663
before ` street ` ).
640
664
641
- When executing a mutation, the selections in the top most selection set will be
665
+ When perfoming a mutation, the selections in the top most selection set will be
642
666
executed in serial order, starting with the first appearing field textually.
643
667
644
668
When executing a collected fields map serially, the executor must consider each
@@ -788,9 +812,9 @@ CoerceArgumentValues(objectType, field, variableValues):
788
812
Any _ request error_ raised as a result of input coercion during
789
813
{CoerceArgumentValues()} should be treated instead as an _ execution error_ .
790
814
791
- Note: Variable values are not coerced because they are expected to be coerced
792
- before executing the operation in {CoerceVariableValues()}, and valid operations
793
- must only allow usage of variables of appropriate types.
815
+ Note: Variable values are not coerced because they are expected to be coerced by
816
+ {CoerceVariableValues()} before _ execution _ begins , and valid operations must
817
+ only allow usage of variables of appropriate types.
794
818
795
819
Note: Implementations are encouraged to optimize the coercion of an argument's
796
820
default value by doing so only once and caching the resulting coerced value.
0 commit comments