@@ -18,9 +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 {ExecuteRequest (schema, document,
22- operationName, variableValues, initialValue)} produces the response, to be
23- formatted according to the Response section below.
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.
2424
2525Implementations should not add additional properties to a _ request_ , which may
2626conflict with future editions of the GraphQL specification. Instead,
@@ -39,27 +39,44 @@ and have no effect on the observable execution, validation, or response of a
3939GraphQL document. Descriptions and comments on executable documents MAY be used
4040for non-observable purposes, such as logging and other developer tools.
4141
42- ## Executing Requests
42+ ## Processing Requests
4343
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
4549operation name to run if the document defines multiple operations, otherwise the
4650document 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_ .
63+
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.
4967
50- ExecuteRequest (schema, document, operationName, variableValues, initialValue):
68+ Request (schema, document, operationName, variableValues, initialValue):
5169
5270- Let {operation} be the result of {GetOperation(document, operationName)}.
5371- Let {coercedVariableValues} be the result of {CoerceVariableValues(schema,
5472 operation, variableValues)}.
5573- If {operation} is a query operation:
56- - Return {ExecuteQuery(operation, schema, coercedVariableValues,
57- initialValue)}.
74+ - Return {Query(operation, schema, coercedVariableValues, initialValue)}.
5875- Otherwise if {operation} is a mutation operation:
59- - Return {ExecuteMutation(operation, schema, coercedVariableValues,
60- initialValue)}.
76+ - Return {Mutation(operation, schema, coercedVariableValues, initialValue)}.
6177- Otherwise if {operation} is a subscription operation:
62- - Return {Subscribe(operation, schema, coercedVariableValues, initialValue)}.
78+ - Return {Subscription(operation, schema, coercedVariableValues,
79+ initialValue)}.
6380
6481GetOperation(document, operationName):
6582
@@ -74,27 +91,28 @@ GetOperation(document, operationName):
7491
7592### Validating Requests
7693
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.
94+ As explained in the Validation section, only operations from documents which
95+ pass all validation rules should be executed. If validation errors are known,
96+ they should be reported in the list of "errors" in the response and the request
97+ must fail without execution.
8198
8299Typically 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.
100+ calling {Request()}, however a GraphQL service may process a request without
101+ immediately validating the document if that exact same document is known to have
102+ been validated before. A GraphQL service should only execute operations which
103+ _ at some point_ were known to be free of any validation errors, and have since
104+ not changed.
87105
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.
106+ For example: the document may be validated during development, provided it does
107+ not later change, or a service may validate a document once and memoize the
108+ result to avoid validating the same document again in the future.
91109
92110### Coercing Variable Values
93111
94112If the operation has defined any variables, then the values for those variables
95113need to be coerced using the input coercion rules of variable's declared type.
96114If a _ request error_ is encountered during input coercion of variable values,
97- then the operation fails without execution .
115+ then the request fails without _ execution _ .
98116
99117CoerceVariableValues(schema, operation, variableValues):
100118
@@ -131,7 +149,11 @@ CoerceVariableValues(schema, operation, variableValues):
131149
132150Note: This algorithm is very similar to {CoerceArgumentValues()}.
133151
134- ## Executing Operations
152+ ## Performing Operations
153+
154+ <a name =" #sec-Executing-Operations " >
155+ <!-- Legacy link, this section was previously titled "Executing Operations" -->
156+ </a >
135157
136158The type system, as described in the "Type System" section of the spec, must
137159provide a query root operation type. If mutations or subscriptions are
@@ -144,9 +166,9 @@ If the operation is a query, the result of the operation is the result of
144166executing the operation’s _ root selection set_ with the query root operation
145167type.
146168
147- An initial value may be provided when executing a query operation.
169+ An initial value may be provided when performing a query operation.
148170
149- ExecuteQuery (query, schema, variableValues, initialValue):
171+ Query (query, schema, variableValues, initialValue):
150172
151173- Let {queryType} be the root Query type in {schema}.
152174- Assert: {queryType} is an Object type.
@@ -164,7 +186,7 @@ It is expected that the top level fields in a mutation operation perform
164186side-effects on the underlying data system. Serial execution of the provided
165187mutations ensures against race conditions during these side-effects.
166188
167- ExecuteMutation (mutation, schema, variableValues, initialValue):
189+ Mutation (mutation, schema, variableValues, initialValue):
168190
169191- Let {mutationType} be the root Mutation type in {schema}.
170192- Assert: {mutationType} is an Object type.
@@ -176,12 +198,13 @@ ExecuteMutation(mutation, schema, variableValues, initialValue):
176198
177199If the operation is a subscription, the result is an _ event stream_ called the
178200_ 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_ .
201+ executing the operation’s _ root selection set_ for each new event on an
202+ underlying _ source stream_ .
180203
181- Executing a subscription operation creates a persistent function on the service
204+ Performing a subscription operation creates a persistent function on the service
182205that maps an underlying _ source stream_ to a returned _ response stream_ .
183206
184- Subscribe (subscription, schema, variableValues, initialValue):
207+ Subscription (subscription, schema, variableValues, initialValue):
185208
186209- Let {sourceStream} be the result of running
187210 {CreateSourceEventStream(subscription, schema, variableValues, initialValue)}.
@@ -190,9 +213,9 @@ Subscribe(subscription, schema, variableValues, initialValue):
190213 variableValues)}.
191214- Return {responseStream}.
192215
193- Note: In a large-scale subscription system, the {Subscribe ()} and
194- {ExecuteSubscriptionEvent ()} algorithms may be run on separate services to
195- maintain predictable scaling properties. See the section below on Supporting
216+ Note: In a large-scale subscription system, the {Subscription ()} and
217+ {SubscriptionEvent ()} algorithms may be run on separate services to maintain
218+ predictable scaling properties. See the section below on Supporting
196219Subscriptions at Scale.
197220
198221As an example, consider a chat application. To subscribe to new messages posted
@@ -313,8 +336,7 @@ MapSourceToResponseEvent(sourceStream, subscription, schema, variableValues):
313336- Let {responseStream} be a new _ event stream_ .
314337- When {sourceStream} emits {sourceValue}:
315338 - Let {executionResult} be the result of running
316- {ExecuteSubscriptionEvent(subscription, schema, variableValues,
317- sourceValue)}.
339+ {SubscriptionEvent(subscription, schema, variableValues, sourceValue)}.
318340 - If internal {error} was raised:
319341 - Cancel {sourceStream}.
320342 - Complete {responseStream} with {error}.
@@ -328,21 +350,21 @@ MapSourceToResponseEvent(sourceStream, subscription, schema, variableValues):
328350 - Complete {responseStream} normally.
329351- Return {responseStream}.
330352
331- Note: Since {ExecuteSubscriptionEvent ()} handles all _ execution error_ , and
332- _ request error_ only occur during {CreateSourceEventStream()}, the only
333- remaining error condition handled from {ExecuteSubscriptionEvent ()} are internal
334- exceptional errors not described by this specification.
353+ Note: Since {SubscriptionEvent ()} handles all _ execution error_ , and _ request
354+ error_ only occur during {CreateSourceEventStream()}, the only remaining error
355+ condition handled from {SubscriptionEvent ()} are internal exceptional errors not
356+ described by this specification.
335357
336- ExecuteSubscriptionEvent (subscription, schema, variableValues, initialValue):
358+ SubscriptionEvent (subscription, schema, variableValues, initialValue):
337359
338360- Let {subscriptionType} be the root Subscription type in {schema}.
339361- Assert: {subscriptionType} is an Object type.
340362- Let {rootSelectionSet} be the _ root selection set_ in {subscription}.
341363- Return {ExecuteRootSelectionSet(variableValues, initialValue,
342364 subscriptionType, rootSelectionSet, "normal")}.
343365
344- Note: The {ExecuteSubscriptionEvent ()} algorithm is intentionally similar to
345- {ExecuteQuery()} since this is how each event result is produced.
366+ Note: The {SubscriptionEvent ()} algorithm is intentionally similar to {Query()}
367+ since this is how each event result is produced.
346368
347369#### Unsubscribe
348370
@@ -638,7 +660,7 @@ A valid GraphQL executor can resolve the four fields in whatever order it chose
638660(however of course ` birthday ` must be resolved before ` month ` , and ` address `
639661before ` street ` ).
640662
641- When executing a mutation, the selections in the top most selection set will be
663+ When performing a mutation, the selections in the top most selection set will be
642664executed in serial order, starting with the first appearing field textually.
643665
644666When executing a collected fields map serially, the executor must consider each
@@ -788,9 +810,9 @@ CoerceArgumentValues(objectType, field, variableValues):
788810Any _ request error_ raised as a result of input coercion during
789811{CoerceArgumentValues()} should be treated instead as an _ execution error_ .
790812
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.
813+ Note: Variable values are not coerced because they are expected to be coerced by
814+ {CoerceVariableValues()} before _ execution _ begins , and valid operations must
815+ only allow usage of variables of appropriate types.
794816
795817Note: Implementations are encouraged to optimize the coercion of an argument's
796818default value by doing so only once and caching the resulting coerced value.
0 commit comments