Skip to content

Commit 370fa75

Browse files
committed
Distinguish between Processing and Execution
1 parent 87f36ca commit 370fa75

File tree

1 file changed

+44
-37
lines changed

1 file changed

+44
-37
lines changed

spec/Section 6 -- Execution.md

+44-37
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,49 @@ A GraphQL service generates a response from a request via execution.
88
- {document}: A {Document} which must contain GraphQL {OperationDefinition} and
99
may contain {FragmentDefinition}.
1010
- {operationName} (optional): The name of the Operation in the Document to
11-
execute.
11+
process.
1212
- {variableValues} (optional): Values for any Variables defined by the
1313
Operation.
1414
- {initialValue} (optional): An initial value corresponding to the root type
1515
being executed. Conceptually, an initial value represents the "universe" of
1616
data available via a GraphQL Service. It is common for a GraphQL Service to
1717
always use the same initial value for every request.
1818

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

23+
:: Formally, _execution_ starts when executing the root selection set in
24+
{ExecuteRootSelectionSet()}. For convenience, this section also contains
25+
preliminary steps required for execution such as coercing variables or getting a
26+
source event stream.
27+
2328
Note: GraphQL requests do not require any specific serialization format or
2429
transport mechanism. Message serialization and transport mechanisms should be
2530
chosen by the implementing service.
2631

27-
## Executing Requests
32+
## Processing Requests
2833

29-
To execute a request, the executor must have a parsed {Document} and a selected
34+
To process a request, the executor must have a parsed {Document} and a selected
3035
operation name to run if the document defines multiple operations, otherwise the
3136
document is expected to only contain a single operation. The result of the
32-
request is determined by the result of executing this operation according to the
33-
"Executing Operations” section below.
37+
request is determined by the result of processing this operation according to
38+
the "Processing Operations” section below.
3439

35-
ExecuteRequest(schema, document, operationName, variableValues, initialValue):
40+
ProcessRequest(schema, document, operationName, variableValues, initialValue):
3641

3742
- Let {operation} be the result of {GetOperation(document, operationName)}.
3843
- Let {coercedVariableValues} be the result of {CoerceVariableValues(schema,
3944
operation, variableValues)}.
4045
- If {operation} is a query operation:
41-
- Return {ExecuteQuery(operation, schema, coercedVariableValues,
46+
- Return {ProcessQuery(operation, schema, coercedVariableValues,
4247
initialValue)}.
4348
- Otherwise if {operation} is a mutation operation:
44-
- Return {ExecuteMutation(operation, schema, coercedVariableValues,
49+
- Return {ProcessMutation(operation, schema, coercedVariableValues,
4550
initialValue)}.
4651
- Otherwise if {operation} is a subscription operation:
47-
- Return {Subscribe(operation, schema, coercedVariableValues, initialValue)}.
52+
- Return {ProcessSubscription(operation, schema, coercedVariableValues,
53+
initialValue)}.
4854

4955
GetOperation(document, operationName):
5056

@@ -60,14 +66,14 @@ GetOperation(document, operationName):
6066
### Validating Requests
6167

6268
As explained in the Validation section, only requests which pass all validation
63-
rules should be executed. If validation errors are known, they should be
64-
reported in the list of "errors" in the response and the request must fail
65-
without execution.
69+
rules should be process. If validation errors are known, they should be reported
70+
in the list of "errors" in the response and the request must fail without
71+
processing.
6672

6773
Typically validation is performed in the context of a request immediately before
68-
execution, however a GraphQL service may execute a request without immediately
74+
processing, however a GraphQL service may process a request without immediately
6975
validating it if that exact same request is known to have been validated before.
70-
A GraphQL service should only execute requests which _at some point_ were known
76+
A GraphQL service should only process requests which _at some point_ were known
7177
to be free of any validation errors, and have since not changed.
7278

7379
For example: the request may be validated during development, provided it does
@@ -114,7 +120,7 @@ CoerceVariableValues(schema, operation, variableValues):
114120

115121
Note: This algorithm is very similar to {CoerceArgumentValues()}.
116122

117-
## Executing Operations
123+
## Processing Operations
118124

119125
The type system, as described in the "Type System" section of the spec, must
120126
provide a query root operation type. If mutations or subscriptions are
@@ -124,12 +130,12 @@ respectively.
124130
### Query
125131

126132
If the operation is a query, the result of the operation is the result of
127-
executing the operation’s top level _selection set_ with the query root
128-
operation type.
133+
executing the operation’s root _selection set_ with the query root operation
134+
type.
129135

130-
An initial value may be provided when executing a query operation.
136+
An initial value may be provided when processing a query operation.
131137

132-
ExecuteQuery(query, schema, variableValues, initialValue):
138+
ProcessQuery(query, schema, variableValues, initialValue):
133139

134140
- Let {queryType} be the root Query type in {schema}.
135141
- Assert: {queryType} is an Object type.
@@ -140,14 +146,14 @@ ExecuteQuery(query, schema, variableValues, initialValue):
140146
### Mutation
141147

142148
If the operation is a mutation, the result of the operation is the result of
143-
executing the operation’s top level _selection set_ on the mutation root object
144-
type. This selection set should be executed serially.
149+
executing the operation’s root _selection set_ on the mutation root object type.
150+
This selection set should be executed serially.
145151

146152
It is expected that the top level fields in a mutation operation perform
147153
side-effects on the underlying data system. Serial execution of the provided
148154
mutations ensures against race conditions during these side-effects.
149155

150-
ExecuteMutation(mutation, schema, variableValues, initialValue):
156+
ProcessMutation(mutation, schema, variableValues, initialValue):
151157

152158
- Let {mutationType} be the root Mutation type in {schema}.
153159
- Assert: {mutationType} is an Object type.
@@ -159,12 +165,13 @@ ExecuteMutation(mutation, schema, variableValues, initialValue):
159165

160166
If the operation is a subscription, the result is an _event stream_ called the
161167
_response stream_ where each event in the event stream is the result of
162-
executing the operation for each new event on an underlying _source stream_.
168+
executing the operation ’s root _selection set_ for each new event on an
169+
underlying _source stream_.
163170

164-
Executing a subscription operation creates a persistent function on the service
171+
Processing a subscription operation creates a persistent function on the service
165172
that maps an underlying _source stream_ to a returned _response stream_.
166173

167-
Subscribe(subscription, schema, variableValues, initialValue):
174+
ProcessSubscription(subscription, schema, variableValues, initialValue):
168175

169176
- Let {sourceStream} be the result of running
170177
{CreateSourceEventStream(subscription, schema, variableValues, initialValue)}.
@@ -173,8 +180,8 @@ Subscribe(subscription, schema, variableValues, initialValue):
173180
variableValues)}.
174181
- Return {responseStream}.
175182

176-
Note: In a large-scale subscription system, the {Subscribe()} and
177-
{ExecuteSubscriptionEvent()} algorithms may be run on separate services to
183+
Note: In a large-scale subscription system, the {ProcessSubscription()} and
184+
{ProcessSubscriptionEvent()} algorithms may be run on separate services to
178185
maintain predictable scaling properties. See the section below on Supporting
179186
Subscriptions at Scale.
180187

@@ -295,7 +302,7 @@ MapSourceToResponseEvent(sourceStream, subscription, schema, variableValues):
295302
- Let {responseStream} be a new _event stream_.
296303
- When {sourceStream} emits {sourceValue}:
297304
- Let {response} be the result of running
298-
{ExecuteSubscriptionEvent(subscription, schema, variableValues,
305+
{ProcessSubscriptionEvent(subscription, schema, variableValues,
299306
sourceValue)}.
300307
- If internal {error} was raised:
301308
- Cancel {sourceStream}.
@@ -310,21 +317,21 @@ MapSourceToResponseEvent(sourceStream, subscription, schema, variableValues):
310317
- Complete {responseStream} normally.
311318
- Return {responseStream}.
312319

313-
Note: Since {ExecuteSubscriptionEvent()} handles all _field error_, and _request
320+
Note: Since {ProcessSubscriptionEvent()} handles all _field error_, and _request
314321
error_ only occur during {CreateSourceEventStream()}, the only remaining error
315-
condition handled from {ExecuteSubscriptionEvent()} are internal exceptional
322+
condition handled from {ProcessSubscriptionEvent()} are internal exceptional
316323
errors not described by this specification.
317324

318-
ExecuteSubscriptionEvent(subscription, schema, variableValues, initialValue):
325+
ProcessSubscriptionEvent(subscription, schema, variableValues, initialValue):
319326

320327
- Let {subscriptionType} be the root Subscription type in {schema}.
321328
- Assert: {subscriptionType} is an Object type.
322329
- Let {selectionSet} be the top level selection set in {subscription}.
323330
- Return {ExecuteRootSelectionSet(variableValues, initialValue,
324331
subscriptionType, selectionSet)}.
325332

326-
Note: The {ExecuteSubscriptionEvent()} algorithm is intentionally similar to
327-
{ExecuteQuery()} since this is how each event result is produced.
333+
Note: The {ProcessSubscriptionEvent()} algorithm is intentionally similar to
334+
{ProcessQuery()} since this is how each event result is produced.
328335

329336
#### Unsubscribe
330337

@@ -534,7 +541,7 @@ A valid GraphQL executor can resolve the four fields in whatever order it chose
534541
(however of course `birthday` must be resolved before `month`, and `address`
535542
before `street`).
536543

537-
When executing a mutation, the selections in the top most selection set will be
544+
When processing a mutation, the selections in the top most selection set will be
538545
executed in serial order, starting with the first appearing field textually.
539546

540547
When executing a grouped field set serially, the executor must consider each
@@ -679,8 +686,8 @@ CoerceArgumentValues(objectType, field, variableValues):
679686
- Return {coercedValues}.
680687

681688
Note: Variable values are not coerced because they are expected to be coerced
682-
before executing the operation in {CoerceVariableValues()}, and valid operations
683-
must only allow usage of variables of appropriate types.
689+
before processing the operation in {CoerceVariableValues()}, and valid
690+
operations must only allow usage of variables of appropriate types.
684691

685692
### Value Resolution
686693

0 commit comments

Comments
 (0)