@@ -86,11 +86,12 @@ query getZuck {
86
86
}
87
87
```
88
88
89
-
## Field Arguments
89
+
## Arguments
90
90
91
-
Fields may take arguments. These often map directly to function arguments
92
-
within the GraphQL server implementation. We already saw arguments used
93
-
in the global field above.
91
+
Fields and directives may take arguments.
92
+
93
+
These often map directly to function arguments within the GraphQL server
94
+
implementation. We already saw arguments used in the global field above.
94
95
95
96
In this example, we want to query a user's profile picture of a
96
97
specific size:
@@ -119,7 +120,7 @@ Many arguments can exist for a given field:
119
120
120
121
**Arguments are unordered**
121
122
122
-
Field arguments may be provided in any syntactic order and maintain identical
123
+
Arguments may be provided in any syntactic order and maintain identical
123
124
semantic meaning.
124
125
125
126
These two queries are semantically identical:
@@ -195,7 +196,7 @@ the field's name otherwise.
195
196
196
197
## Input Values
197
198
198
-
Both field arguments and directives accept input values. Input values can be
199
+
Field and directive arguments accept input values. Input values can be
199
200
specified as a variable or represented inline as literals. Input values can
200
201
be scalars, enumerations, or input objects. List and inputs objects may also
201
202
contain variables.
@@ -270,26 +271,6 @@ could run this query and request profilePic of size 60 with:
270
271
}
271
272
```
272
273
273
-
## Directives
274
-
275
-
In some cases, you need to provide options to alter GraphQL's execution
276
-
behavior in ways field arguments will not suffice, such as conditionally
277
-
skipping a field. Directives provide this with a `@name` and can be
278
-
specified to be used without an argument or with a value argument.
279
-
280
-
Directives can be used to conditionally include fields in a query based
281
-
on a provided boolean value. In this contrived example experimentalField
282
-
will be queried and controlField will not.
283
-
284
-
```graphql
285
-
query myQuery($someTest: Boolean) {
286
-
experimentalField @if: $someTest,
287
-
controlField @unless: $someTest
288
-
}
289
-
```
290
-
291
-
As future versions of GraphQL adopts new configurable execution capabilities,
292
-
they may be exposed via directives.
293
274
294
275
## Fragments
295
276
@@ -446,3 +427,59 @@ query InlineFragmentTyping {
446
427
}
447
428
```
448
429
430
+
431
+
## Directives
432
+
433
+
In some cases, you need to provide options to alter GraphQL's execution
434
+
behavior in ways field arguments will not suffice, such as conditionally
435
+
including or skipping a field. Directives provide this by describing additional information to the executor.
436
+
437
+
Directives have a name along with a list of arguments which may accept values
438
+
of any input type.
439
+
440
+
Directives can be used to describe additional information for fields, fragments,
441
+
and operations.
442
+
443
+
As future versions of GraphQL adopts new configurable execution capabilities,
444
+
they may be exposed via directives.
445
+
446
+
### Fragment Directives
447
+
448
+
Fragments may include directives to alter their behavior. At runtime, the directives provided on a fragment spread override those described on the
449
+
definition.
450
+
451
+
For example, the following query:
452
+
453
+
```graphql
454
+
query HasConditionalFragment($condition: Boolean) {
455
+
...MaybeFragment @include(if: $condition)
456
+
}
457
+
458
+
fragment MaybeFragment on Query {
459
+
me {
460
+
name
461
+
}
462
+
}
463
+
```
464
+
465
+
Will have identical runtime behavior as
466
+
467
+
```graphql
468
+
query HasConditionalFragment($condition: Boolean) {
469
+
...MaybeFragment
470
+
}
471
+
472
+
fragment MaybeFragment on Query @include(if: $condition) {
473
+
me {
474
+
name
475
+
}
476
+
}
477
+
```
478
+
479
+
FragmentSpreadDirectives(fragmentSpread) :
480
+
* Let {directives} be the set of directives on {fragmentSpread}
481
+
* Let {fragmentDefinition} be the FragmentDefinition in the document named {fragmentSpread} refers to.
482
+
* For each {directive} in directives on {fragmentDefinition}
483
+
* If {directives} does not contain a directive named {directive}.
484
+
* Add {directive} into {directives}
485
+
* Return {directives}
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4