Skip to content

Commit 11f33ba

Browse files
committed
Editorial and eliding
1 parent 2fcc58b commit 11f33ba

File tree

1 file changed

+66
-58
lines changed

1 file changed

+66
-58
lines changed

spec/Section 6 -- Execution.md

Lines changed: 66 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,9 @@ 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 {ProcessRequest(schema, document,
22-
operationName, variableValues, initialValue)} produces the response, to be
23-
formatted according to the Response section below.
24-
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.
21+
Given this information, the result of {Request(schema, document, operationName,
22+
variableValues, initialValue)} produces the response, to be formatted according
23+
to the Response section below.
2924

3025
Implementations should not add additional properties to a _request_, which may
3126
conflict with future editions of the GraphQL specification. Instead,
@@ -40,34 +35,43 @@ chosen by the implementing service.
4035

4136
## Processing Requests
4237

38+
<a name="#sec-Executing-Requests">
39+
<!-- Legacy link, this section was previously titled "Executing Requests" -->
40+
</a>
41+
4342
To process a request, the executor must have a parsed {Document} and a selected
4443
operation name to run if the document defines multiple operations, otherwise the
4544
document is expected to only contain a single operation. The result of the
46-
request is determined by the result of processing this operation according to
47-
the "Processing Operations” section below.
45+
request is determined by the result of performing this operation according to
46+
the "Performing Operations” section below.
47+
48+
:: We define _execution_ as the process of executing the operation's _root
49+
selection set_ through {ExecuteRootSelectionSet()}, and hence _execution_ begins
50+
when {ExecuteSelectionSet()} is called for the first time in a request.
51+
52+
Note: A subscription operation may call {ExecuteSelectionSet()} a number of
53+
times.
4854

49-
:: We define _execution_ as the process of executing the operation's root
50-
selection set through {ExecuteSelectionSet()}, thus _execution_ begins when
51-
{ExecuteSelectionSet()} is called for the first time in a request. The
52-
{ExecuteRequest()} algorithm contains the preamble for _execution_, followed by
53-
the _execution_ itself.
55+
The {Request()} algorithm contains the preamble for execution, handling concerns
56+
such as determining the operation and coercing the inputs, before passing the
57+
request on to the relevant algorithm for the operation's type which then
58+
performs any other necessary preliminary steps (for example establishing the
59+
source event stream for subscription operations) and then initiates _execution_.
5460

5561
Note: An error raised before _execution_ begins will typically be a _request
56-
error_, and once _execution_ begins will typically be a _field error_.
62+
error_, and once _execution_ begins will typically be an _execution error_.
5763

58-
ProcessRequest(schema, document, operationName, variableValues, initialValue):
64+
Request(schema, document, operationName, variableValues, initialValue):
5965

6066
- Let {operation} be the result of {GetOperation(document, operationName)}.
6167
- Let {coercedVariableValues} be the result of {CoerceVariableValues(schema,
6268
operation, variableValues)}.
6369
- If {operation} is a query operation:
64-
- Return {ProcessQuery(operation, schema, coercedVariableValues,
65-
initialValue)}.
70+
- Return {Query(operation, schema, coercedVariableValues, initialValue)}.
6671
- Otherwise if {operation} is a mutation operation:
67-
- Return {ProcessMutation(operation, schema, coercedVariableValues,
68-
initialValue)}.
72+
- Return {Mutation(operation, schema, coercedVariableValues, initialValue)}.
6973
- Otherwise if {operation} is a subscription operation:
70-
- Return {ProcessSubscription(operation, schema, coercedVariableValues,
74+
- Return {Subscription(operation, schema, coercedVariableValues,
7175
initialValue)}.
7276

7377
GetOperation(document, operationName):
@@ -83,27 +87,28 @@ GetOperation(document, operationName):
8387

8488
### Validating Requests
8589

86-
As explained in the Validation section, only requests which pass all validation
87-
rules should be processed. If validation errors are known, they should be
88-
reported in the list of "errors" in the response and the request must fail
89-
without processing.
90+
As explained in the Validation section, only operations from documents which
91+
pass all validation rules should be executed. If validation errors are known,
92+
they should be reported in the list of "errors" in the response and the request
93+
must fail without execution.
9094

9195
Typically validation is performed in the context of a request immediately before
92-
processing, however a GraphQL service may execute a process without immediately
93-
validating it if that exact same request is known to have been validated before.
94-
A GraphQL service should only process requests which _at some point_ were known
95-
to be free of any validation errors, and have since not changed.
96+
processing, however a GraphQL service may process a request without immediately
97+
validating the document if that exact same document is known to have been
98+
validated before. A GraphQL service should only execute operations which _at
99+
some point_ were known to be free of any validation errors, and have since not
100+
changed.
96101

97-
For example: the request may be validated during development, provided it does
98-
not later change, or a service may validate a request once and memoize the
99-
result to avoid validating the same request again in the future.
102+
For example: the document may be validated during development, provided it does
103+
not later change, or a service may validate a document once and memoize the
104+
result to avoid validating the same document again in the future.
100105

101106
### Coercing Variable Values
102107

103108
If the operation has defined any variables, then the values for those variables
104109
need to be coerced using the input coercion rules of variable's declared type.
105110
If a _request error_ is encountered during input coercion of variable values,
106-
then the operation fails without _execution_.
111+
then the request fails without _execution_.
107112

108113
CoerceVariableValues(schema, operation, variableValues):
109114

@@ -138,7 +143,11 @@ CoerceVariableValues(schema, operation, variableValues):
138143

139144
Note: This algorithm is very similar to {CoerceArgumentValues()}.
140145

141-
## Processing Operations
146+
## Performing Operations
147+
148+
<a name="#sec-Executing-Operations">
149+
<!-- Legacy link, this section was previously titled "Executing Operations" -->
150+
</a>
142151

143152
The type system, as described in the "Type System" section of the spec, must
144153
provide a query root operation type. If mutations or subscriptions are
@@ -151,9 +160,9 @@ If the operation is a query, the result of the operation is the result of
151160
executing the operation’s _root selection set_ with the query root operation
152161
type.
153162

154-
An initial value may be provided when processing a query operation.
163+
An initial value may be provided when performing a query operation.
155164

156-
ProcessQuery(query, schema, variableValues, initialValue):
165+
Query(query, schema, variableValues, initialValue):
157166

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

174-
ProcessMutation(mutation, schema, variableValues, initialValue):
183+
Mutation(mutation, schema, variableValues, initialValue):
175184

176185
- Let {mutationType} be the root Mutation type in {schema}.
177186
- Assert: {mutationType} is an Object type.
@@ -183,13 +192,13 @@ ProcessMutation(mutation, schema, variableValues, initialValue):
183192

184193
If the operation is a subscription, the result is an _event stream_ called the
185194
_response stream_ where each event in the event stream is the result of
186-
executing the operation’s root _selection set_ for each new event on an
195+
executing the operation’s _root selection set_ for each new event on an
187196
underlying _source stream_.
188197

189-
Processing a subscription operation creates a persistent function on the service
198+
Performing a subscription operation creates a persistent function on the service
190199
that maps an underlying _source stream_ to a returned _response stream_.
191200

192-
ProcessSubscription(subscription, schema, variableValues, initialValue):
201+
Subscription(subscription, schema, variableValues, initialValue):
193202

194203
- Let {sourceStream} be the result of running
195204
{CreateSourceEventStream(subscription, schema, variableValues, initialValue)}.
@@ -198,9 +207,9 @@ ProcessSubscription(subscription, schema, variableValues, initialValue):
198207
variableValues)}.
199208
- Return {responseStream}.
200209

201-
Note: In a large-scale subscription system, the {ProcessSubscription()} and
202-
{ProcessSubscriptionEvent()} algorithms may be run on separate services to
203-
maintain predictable scaling properties. See the section below on Supporting
210+
Note: In a large-scale subscription system, the {Subscription()} and
211+
{SubscriptionEvent()} algorithms may be run on separate services to maintain
212+
predictable scaling properties. See the section below on Supporting
204213
Subscriptions at Scale.
205214

206215
As an example, consider a chat application. To subscribe to new messages posted
@@ -319,9 +328,8 @@ MapSourceToResponseEvent(sourceStream, subscription, schema, variableValues):
319328

320329
- Let {responseStream} be a new _event stream_.
321330
- When {sourceStream} emits {sourceValue}:
322-
- Let {response} be the result of running
323-
{ProcessSubscriptionEvent(subscription, schema, variableValues,
324-
sourceValue)}.
331+
- Let {response} be the result of running {SubscriptionEvent(subscription,
332+
schema, variableValues, sourceValue)}.
325333
- If internal {error} was raised:
326334
- Cancel {sourceStream}.
327335
- Complete {responseStream} with {error}.
@@ -335,21 +343,21 @@ MapSourceToResponseEvent(sourceStream, subscription, schema, variableValues):
335343
- Complete {responseStream} normally.
336344
- Return {responseStream}.
337345

338-
Note: Since {ProcessSubscriptionEvent()} handles all _execution error_, and
339-
_request error_ only occur during {CreateSourceEventStream()}, the only
340-
remaining error condition handled from {ProcessSubscriptionEvent()} are internal
341-
exceptional errors not described by this specification.
346+
Note: Since {SubscriptionEvent()} handles all _execution error_, and _request
347+
error_ only occur during {CreateSourceEventStream()}, the only remaining error
348+
condition handled from {SubscriptionEvent()} are internal exceptional errors not
349+
described by this specification.
342350

343-
ProcessSubscriptionEvent(subscription, schema, variableValues, initialValue):
351+
SubscriptionEvent(subscription, schema, variableValues, initialValue):
344352

345353
- Let {subscriptionType} be the root Subscription type in {schema}.
346354
- Assert: {subscriptionType} is an Object type.
347355
- Let {rootSelectionSet} be the _root selection set_ in {subscription}.
348356
- Return {ExecuteRootSelectionSet(variableValues, initialValue,
349357
subscriptionType, rootSelectionSet, "normal")}.
350358

351-
Note: The {ProcessSubscriptionEvent()} algorithm is intentionally similar to
352-
{ProcessQuery()} since this is how each event result is produced.
359+
Note: The {SubscriptionEvent()} algorithm is intentionally similar to {Query()}
360+
since this is how each event result is produced.
353361

354362
#### Unsubscribe
355363

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

647-
When processing a mutation, the selections in the top most selection set will be
655+
When performing a mutation, the selections in the top most selection set will be
648656
executed in serial order, starting with the first appearing field textually.
649657

650658
When executing a grouped field set serially, the executor must consider each
@@ -791,9 +799,9 @@ CoerceArgumentValues(objectType, field, variableValues):
791799
Any _request error_ raised as a result of input coercion during
792800
{CoerceArgumentValues()} should be treated instead as an _execution error_.
793801

794-
Note: Variable values are not coerced because they are expected to be coerced
795-
before processing the operation in {CoerceVariableValues()}, and valid
796-
operations must only allow usage of variables of appropriate types.
802+
Note: Variable values are not coerced because they are expected to be coerced in
803+
{CoerceVariableValues()} before _execution_ begins, and valid operations must
804+
only allow usage of variables of appropriate types.
797805

798806
### Value Resolution
799807

0 commit comments

Comments
 (0)