Skip to content

Commit 2fcc58b

Browse files
committed
Merge remote-tracking branch 'martinbonnin/clarify-execution' into before-execution-begins-note
2 parents 7a740be + 41450b7 commit 2fcc58b

File tree

1 file changed

+38
-31
lines changed

1 file changed

+38
-31
lines changed

spec/Section 6 -- Execution.md

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@ A GraphQL service generates a response from a request via execution.
1818
- {extensions} (optional): A map reserved for implementation-specific additional
1919
information.
2020

21-
Given this information, the result of {ExecuteRequest(schema, document,
21+
Given this information, the result of {ProcessRequest(schema, document,
2222
operationName, variableValues, initialValue)} produces the response, to be
2323
formatted according to the Response section below.
2424

25+
:: Formally, _execution_ starts when executing the root selection set in
26+
{ExecuteRootSelectionSet()}. For convenience, this section also contains
27+
preliminary steps required for execution such as coercing variables or getting a
28+
source event stream.
29+
2530
Implementations should not add additional properties to a _request_, which may
2631
conflict with future editions of the GraphQL specification. Instead,
2732
{extensions} provides a reserved location for implementation-specific additional
@@ -33,13 +38,13 @@ Note: GraphQL requests do not require any specific serialization format or
3338
transport mechanism. Message serialization and transport mechanisms should be
3439
chosen by the implementing service.
3540

36-
## Executing Requests
41+
## Processing Requests
3742

38-
To execute a request, the executor must have a parsed {Document} and a selected
43+
To process a request, the executor must have a parsed {Document} and a selected
3944
operation name to run if the document defines multiple operations, otherwise the
4045
document is expected to only contain a single operation. The result of the
41-
request is determined by the result of executing this operation according to the
42-
"Executing Operations” section below.
46+
request is determined by the result of processing this operation according to
47+
the "Processing Operations” section below.
4348

4449
:: We define _execution_ as the process of executing the operation's root
4550
selection set through {ExecuteSelectionSet()}, thus _execution_ begins when
@@ -50,19 +55,20 @@ the _execution_ itself.
5055
Note: An error raised before _execution_ begins will typically be a _request
5156
error_, and once _execution_ begins will typically be a _field error_.
5257

53-
ExecuteRequest(schema, document, operationName, variableValues, initialValue):
58+
ProcessRequest(schema, document, operationName, variableValues, initialValue):
5459

5560
- Let {operation} be the result of {GetOperation(document, operationName)}.
5661
- Let {coercedVariableValues} be the result of {CoerceVariableValues(schema,
5762
operation, variableValues)}.
5863
- If {operation} is a query operation:
59-
- Return {ExecuteQuery(operation, schema, coercedVariableValues,
64+
- Return {ProcessQuery(operation, schema, coercedVariableValues,
6065
initialValue)}.
6166
- Otherwise if {operation} is a mutation operation:
62-
- Return {ExecuteMutation(operation, schema, coercedVariableValues,
67+
- Return {ProcessMutation(operation, schema, coercedVariableValues,
6368
initialValue)}.
6469
- Otherwise if {operation} is a subscription operation:
65-
- Return {Subscribe(operation, schema, coercedVariableValues, initialValue)}.
70+
- Return {ProcessSubscription(operation, schema, coercedVariableValues,
71+
initialValue)}.
6672

6773
GetOperation(document, operationName):
6874

@@ -78,14 +84,14 @@ GetOperation(document, operationName):
7884
### Validating Requests
7985

8086
As explained in the Validation section, only requests which pass all validation
81-
rules should be executed. If validation errors are known, they should be
87+
rules should be processed. If validation errors are known, they should be
8288
reported in the list of "errors" in the response and the request must fail
83-
without _execution_.
89+
without processing.
8490

8591
Typically validation is performed in the context of a request immediately before
86-
_execution_, however a GraphQL service may execute a request without immediately
92+
processing, however a GraphQL service may execute a process without immediately
8793
validating it if that exact same request is known to have been validated before.
88-
A GraphQL service should only execute requests which _at some point_ were known
94+
A GraphQL service should only process requests which _at some point_ were known
8995
to be free of any validation errors, and have since not changed.
9096

9197
For example: the request may be validated during development, provided it does
@@ -132,7 +138,7 @@ CoerceVariableValues(schema, operation, variableValues):
132138

133139
Note: This algorithm is very similar to {CoerceArgumentValues()}.
134140

135-
## Executing Operations
141+
## Processing Operations
136142

137143
The type system, as described in the "Type System" section of the spec, must
138144
provide a query root operation type. If mutations or subscriptions are
@@ -145,9 +151,9 @@ If the operation is a query, the result of the operation is the result of
145151
executing the operation’s _root selection set_ with the query root operation
146152
type.
147153

148-
An initial value may be provided when executing a query operation.
154+
An initial value may be provided when processing a query operation.
149155

150-
ExecuteQuery(query, schema, variableValues, initialValue):
156+
ProcessQuery(query, schema, variableValues, initialValue):
151157

152158
- Let {queryType} be the root Query type in {schema}.
153159
- Assert: {queryType} is an Object type.
@@ -165,7 +171,7 @@ It is expected that the top level fields in a mutation operation perform
165171
side-effects on the underlying data system. Serial execution of the provided
166172
mutations ensures against race conditions during these side-effects.
167173

168-
ExecuteMutation(mutation, schema, variableValues, initialValue):
174+
ProcessMutation(mutation, schema, variableValues, initialValue):
169175

170176
- Let {mutationType} be the root Mutation type in {schema}.
171177
- Assert: {mutationType} is an Object type.
@@ -177,12 +183,13 @@ ExecuteMutation(mutation, schema, variableValues, initialValue):
177183

178184
If the operation is a subscription, the result is an _event stream_ called the
179185
_response stream_ where each event in the event stream is the result of
180-
executing the operation for each new event on an underlying _source stream_.
186+
executing the operation’s root _selection set_ for each new event on an
187+
underlying _source stream_.
181188

182-
Executing a subscription operation creates a persistent function on the service
189+
Processing a subscription operation creates a persistent function on the service
183190
that maps an underlying _source stream_ to a returned _response stream_.
184191

185-
Subscribe(subscription, schema, variableValues, initialValue):
192+
ProcessSubscription(subscription, schema, variableValues, initialValue):
186193

187194
- Let {sourceStream} be the result of running
188195
{CreateSourceEventStream(subscription, schema, variableValues, initialValue)}.
@@ -191,8 +198,8 @@ Subscribe(subscription, schema, variableValues, initialValue):
191198
variableValues)}.
192199
- Return {responseStream}.
193200

194-
Note: In a large-scale subscription system, the {Subscribe()} and
195-
{ExecuteSubscriptionEvent()} algorithms may be run on separate services to
201+
Note: In a large-scale subscription system, the {ProcessSubscription()} and
202+
{ProcessSubscriptionEvent()} algorithms may be run on separate services to
196203
maintain predictable scaling properties. See the section below on Supporting
197204
Subscriptions at Scale.
198205

@@ -313,7 +320,7 @@ MapSourceToResponseEvent(sourceStream, subscription, schema, variableValues):
313320
- Let {responseStream} be a new _event stream_.
314321
- When {sourceStream} emits {sourceValue}:
315322
- Let {response} be the result of running
316-
{ExecuteSubscriptionEvent(subscription, schema, variableValues,
323+
{ProcessSubscriptionEvent(subscription, schema, variableValues,
317324
sourceValue)}.
318325
- If internal {error} was raised:
319326
- Cancel {sourceStream}.
@@ -328,21 +335,21 @@ MapSourceToResponseEvent(sourceStream, subscription, schema, variableValues):
328335
- Complete {responseStream} normally.
329336
- Return {responseStream}.
330337

331-
Note: Since {ExecuteSubscriptionEvent()} handles all _execution error_, and
338+
Note: Since {ProcessSubscriptionEvent()} handles all _execution error_, and
332339
_request error_ only occur during {CreateSourceEventStream()}, the only
333-
remaining error condition handled from {ExecuteSubscriptionEvent()} are internal
340+
remaining error condition handled from {ProcessSubscriptionEvent()} are internal
334341
exceptional errors not described by this specification.
335342

336-
ExecuteSubscriptionEvent(subscription, schema, variableValues, initialValue):
343+
ProcessSubscriptionEvent(subscription, schema, variableValues, initialValue):
337344

338345
- Let {subscriptionType} be the root Subscription type in {schema}.
339346
- Assert: {subscriptionType} is an Object type.
340347
- Let {rootSelectionSet} be the _root selection set_ in {subscription}.
341348
- Return {ExecuteRootSelectionSet(variableValues, initialValue,
342349
subscriptionType, rootSelectionSet, "normal")}.
343350

344-
Note: The {ExecuteSubscriptionEvent()} algorithm is intentionally similar to
345-
{ExecuteQuery()} since this is how each event result is produced.
351+
Note: The {ProcessSubscriptionEvent()} algorithm is intentionally similar to
352+
{ProcessQuery()} since this is how each event result is produced.
346353

347354
#### Unsubscribe
348355

@@ -637,7 +644,7 @@ A valid GraphQL executor can resolve the four fields in whatever order it chose
637644
(however of course `birthday` must be resolved before `month`, and `address`
638645
before `street`).
639646

640-
When executing a mutation, the selections in the top most selection set will be
647+
When processing a mutation, the selections in the top most selection set will be
641648
executed in serial order, starting with the first appearing field textually.
642649

643650
When executing a grouped field set serially, the executor must consider each
@@ -785,8 +792,8 @@ Any _request error_ raised as a result of input coercion during
785792
{CoerceArgumentValues()} should be treated instead as an _execution error_.
786793

787794
Note: Variable values are not coerced because they are expected to be coerced
788-
before executing the operation in {CoerceVariableValues()}, and valid operations
789-
must only allow usage of variables of appropriate types.
795+
before processing the operation in {CoerceVariableValues()}, and valid
796+
operations must only allow usage of variables of appropriate types.
790797

791798
### Value Resolution
792799

0 commit comments

Comments
 (0)