@@ -1251,10 +1251,15 @@ avoiding costly string building in clients at runtime.
12511251If not defined as constant (for example, in {DefaultValue}), a {Variable} can be
12521252supplied for an input value.
12531253
1254- Variables must be defined at the top of an operation and are in scope throughout
1255- the execution of that operation. Values for those variables are provided to a
1256- GraphQL service as part of a request so they may be substituted in during
1257- execution.
1254+ :: An _ operation variable_ is a variable defined at the top of an operation. An
1255+ operation variable is in scope throughout the execution of that operation.
1256+ Values for operation variables are provided to a GraphQL service as part of a
1257+ request so they may be substituted in during execution.
1258+
1259+ :: A _ fragment variable_ is a variable defined on a fragment. A fragment
1260+ variable is locally scoped, it may only be referenced within that fragment
1261+ (non-transitively). Values for fragment variables are provided to fragment
1262+ spreads.
12581263
12591264In this example, we want to fetch a profile picture size based on the size of a
12601265particular device:
@@ -1283,20 +1288,21 @@ size `60`:
12831288
12841289** Variable Use Within Fragments**
12851290
1286- Variables can be used within fragments. Operation-defined variables have global
1287- scope within a given operation. Fragment-defined variables have local scope
1288- within the fragment definition in which they are defined. A variable used within
1289- a fragment must either be declared in each top-level operation that transitively
1290- consumes that fragment, or by that same fragment as a fragment variable
1291- definition. If a variable referenced in a fragment is included by an operation
1292- where neither the fragment nor the operation defines that variable, that
1293- operation is invalid (see
1291+ Variables can be used within fragments. An _ operation variable_ has global scope
1292+ within that operation, including within any fragments that operation
1293+ transitively consumes. A variable used within a fragment must either be defined
1294+ by that fragment, or must be declared in each top-level operation that
1295+ transitively consumes that fragment. If a variable referenced in a fragment is
1296+ defined in both the fragment and the operation, the fragment definition will be
1297+ used. If a variable is referenced in a fragment and is not defined by that
1298+ fragment, then any operation that transitively references the fragment and does
1299+ not define that variable is invalid (see
12941300[ All Variable Uses Defined] ( #sec-All-Variable-Uses-Defined ) ).
12951301
12961302## Fragment Variable Definitions
12971303
1298- Fragments may define locally scoped variables. This allows fragments to be
1299- reused while enabling the caller to specify the fragment's behavior.
1304+ Fragments may define locally scoped variables. This allows the caller to specify
1305+ the fragment's behavior.
13001306
13011307For example, the profile picture may need to be a different size depending on
13021308the parent context:
@@ -1321,8 +1327,8 @@ fragment dynamicProfilePic($size: Int! = 50) on User {
13211327In this case the ` user ` will have a larger ` profilePic ` than those found in the
13221328list of ` friends ` .
13231329
1324- A fragment-defined variable is scoped to the fragment that defines it.
1325- Fragment-defined variables are allowed to shadow operation-defined variables .
1330+ A _ fragment variable _ is scoped to the fragment that defines it. A fragment
1331+ variable may shadow an _ operation variable _ .
13261332
13271333``` graphql example
13281334query withShadowedVariables ($size : Int ! ) {
@@ -1343,11 +1349,11 @@ fragment dynamicProfilePic($size: Int!) on User {
13431349}
13441350```
13451351
1346- The profilePic for ` user ` will be determined by the variables set by the
1347- operation, while ` secondUser ` will always have a ` profilePic ` of size ` 10 ` . In
1348- this case, the fragment ` variableProfilePic ` uses the operation-defined
1349- variable , while ` dynamicProfilePic ` uses the value passed in via the fragment
1350- spread's ` size ` argument.
1352+ In the example above, the profilePic for ` user ` will be determined by the
1353+ variables set by the operation, while ` secondUser ` will always have a
1354+ ` profilePic ` of size ` 10 ` . In this case, the fragment ` variableProfilePic ` uses
1355+ the value of the _ operation variable _ , while ` dynamicProfilePic ` uses the value
1356+ of the _ fragment variable _ passed in via the fragment spread's ` size ` argument.
13511357
13521358## Type References
13531359
0 commit comments