@@ -18,7 +18,7 @@ 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 {Request (schema, document,
2222operationName, variableValues, initialValue)} produces the response, to be
2323formatted according to the Response section below.
2424
@@ -39,27 +39,45 @@ 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_ .
4963
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):
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,
74+ - Return {Query (operation, schema, coercedVariableValues,
5775 initialValue)}.
5876- Otherwise if {operation} is a mutation operation:
59- - Return {ExecuteMutation (operation, schema, coercedVariableValues,
77+ - Return {Mutation (operation, schema, coercedVariableValues,
6078 initialValue)}.
6179- Otherwise if {operation} is a subscription operation:
62- - Return {Subscribe (operation, schema, coercedVariableValues, initialValue)}.
80+ - Return {Subscription (operation, schema, coercedVariableValues, initialValue)}.
6381
6482GetOperation(document, operationName):
6583
@@ -74,27 +92,28 @@ GetOperation(document, operationName):
7492
7593### Validating Requests
7694
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.
8199
82100Typically 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.
87106
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.
91110
92111### Coercing Variable Values
93112
94113If the operation has defined any variables, then the values for those variables
95114need to be coerced using the input coercion rules of variable's declared type.
96115If 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 _ .
98117
99118CoerceVariableValues(schema, operation, variableValues):
100119
@@ -131,7 +150,11 @@ CoerceVariableValues(schema, operation, variableValues):
131150
132151Note: This algorithm is very similar to {CoerceArgumentValues()}.
133152
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 >
135158
136159The type system, as described in the "Type System" section of the spec, must
137160provide 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
144167executing the operation’s _ root selection set_ with the query root operation
145168type.
146169
147- An initial value may be provided when executing a query operation.
170+ An initial value may be provided when perfoming a query operation.
148171
149- ExecuteQuery (query, schema, variableValues, initialValue):
172+ Query (query, schema, variableValues, initialValue):
150173
151174- Let {queryType} be the root Query type in {schema}.
152175- Assert: {queryType} is an Object type.
@@ -164,7 +187,7 @@ It is expected that the top level fields in a mutation operation perform
164187side-effects on the underlying data system. Serial execution of the provided
165188mutations ensures against race conditions during these side-effects.
166189
167- ExecuteMutation (mutation, schema, variableValues, initialValue):
190+ Mutation (mutation, schema, variableValues, initialValue):
168191
169192- Let {mutationType} be the root Mutation type in {schema}.
170193- Assert: {mutationType} is an Object type.
@@ -176,12 +199,13 @@ ExecuteMutation(mutation, schema, variableValues, initialValue):
176199
177200If the operation is a subscription, the result is an _ event stream_ called the
178201_ 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_ .
180204
181- Executing a subscription operation creates a persistent function on the service
205+ Perfoming a subscription operation creates a persistent function on the service
182206that maps an underlying _ source stream_ to a returned _ response stream_ .
183207
184- Subscribe (subscription, schema, variableValues, initialValue):
208+ Subscription (subscription, schema, variableValues, initialValue):
185209
186210- Let {sourceStream} be the result of running
187211 {CreateSourceEventStream(subscription, schema, variableValues, initialValue)}.
@@ -190,8 +214,8 @@ Subscribe(subscription, schema, variableValues, initialValue):
190214 variableValues)}.
191215- Return {responseStream}.
192216
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
195219maintain predictable scaling properties. See the section below on Supporting
196220Subscriptions at Scale.
197221
@@ -313,7 +337,7 @@ MapSourceToResponseEvent(sourceStream, subscription, schema, variableValues):
313337- Let {responseStream} be a new _ event stream_ .
314338- When {sourceStream} emits {sourceValue}:
315339 - Let {executionResult} be the result of running
316- {ExecuteSubscriptionEvent (subscription, schema, variableValues,
340+ {SubscriptionEvent (subscription, schema, variableValues,
317341 sourceValue)}.
318342 - If internal {error} was raised:
319343 - Cancel {sourceStream}.
@@ -328,21 +352,21 @@ MapSourceToResponseEvent(sourceStream, subscription, schema, variableValues):
328352 - Complete {responseStream} normally.
329353- Return {responseStream}.
330354
331- Note: Since {ExecuteSubscriptionEvent ()} handles all _ execution error_ , and
355+ Note: Since {SubscriptionEvent ()} handles all _ execution error_ , and
332356_ 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
334358exceptional errors not described by this specification.
335359
336- ExecuteSubscriptionEvent (subscription, schema, variableValues, initialValue):
360+ SubscriptionEvent (subscription, schema, variableValues, initialValue):
337361
338362- Let {subscriptionType} be the root Subscription type in {schema}.
339363- Assert: {subscriptionType} is an Object type.
340364- Let {rootSelectionSet} be the _ root selection set_ in {subscription}.
341365- Return {ExecuteRootSelectionSet(variableValues, initialValue,
342366 subscriptionType, rootSelectionSet, "normal")}.
343367
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.
346370
347371#### Unsubscribe
348372
@@ -638,7 +662,7 @@ A valid GraphQL executor can resolve the four fields in whatever order it chose
638662(however of course ` birthday ` must be resolved before ` month ` , and ` address `
639663before ` street ` ).
640664
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
642666executed in serial order, starting with the first appearing field textually.
643667
644668When executing a collected fields map serially, the executor must consider each
@@ -788,9 +812,9 @@ CoerceArgumentValues(objectType, field, variableValues):
788812Any _ request error_ raised as a result of input coercion during
789813{CoerceArgumentValues()} should be treated instead as an _ execution error_ .
790814
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.
794818
795819Note: Implementations are encouraged to optimize the coercion of an argument's
796820default value by doing so only once and caching the resulting coerced value.
0 commit comments