Skip to content

Commit a6d7110

Browse files
committed
remove labels
1 parent 1a4164c commit a6d7110

File tree

4 files changed

+35
-146
lines changed

4 files changed

+35
-146
lines changed

spec/Section 3 -- Type System.md

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,10 +2126,7 @@ scalar UUID @specifiedBy(url: "https://tools.ietf.org/html/rfc4122")
21262126
### @defer
21272127

21282128
```graphql
2129-
directive @defer(
2130-
label: String
2131-
if: Boolean! = true
2132-
) on FRAGMENT_SPREAD | INLINE_FRAGMENT
2129+
directive @defer(if: Boolean! = true) on FRAGMENT_SPREAD | INLINE_FRAGMENT
21332130
```
21342131

21352132
The `@defer` directive may be provided for fragment spreads and inline fragments
@@ -2144,7 +2141,7 @@ delivered in a subsequent response. `@include` and `@skip` take precedence over
21442141
query myQuery($shouldDefer: Boolean) {
21452142
user {
21462143
name
2147-
...someFragment @defer(label: "someLabel", if: $shouldDefer)
2144+
...someFragment @defer(if: $shouldDefer)
21482145
}
21492146
}
21502147
fragment someFragment on User {
@@ -2161,20 +2158,11 @@ fragment someFragment on User {
21612158
[related note](#note-088b7)). When `false`, fragment will not be deferred and
21622159
data will be included in the initial response. Defaults to `true` when
21632160
omitted.
2164-
- `label: String` - May be used by GraphQL clients to identify the data from
2165-
responses and associate it with the corresponding defer directive. If
2166-
provided, the GraphQL service must add it to the corresponding payload.
2167-
`label` must be unique label across all `@defer` and `@stream` directives in a
2168-
document. `label` must not be provided as a variable.
21692161

21702162
### @stream
21712163

21722164
```graphql
2173-
directive @stream(
2174-
label: String
2175-
if: Boolean! = true
2176-
initialCount: Int = 0
2177-
) on FIELD
2165+
directive @stream(if: Boolean! = true, initialCount: Int = 0) on FIELD
21782166
```
21792167

21802168
The `@stream` directive may be provided for a field of `List` type so that the
@@ -2186,7 +2174,7 @@ responses. `@include` and `@skip` take precedence over `@stream`.
21862174
query myQuery($shouldStream: Boolean) {
21872175
user {
21882176
friends(first: 10) {
2189-
nodes @stream(label: "friendsStream", initialCount: 5, if: $shouldStream)
2177+
nodes @stream(initialCount: 5, if: $shouldStream)
21902178
}
21912179
}
21922180
}
@@ -2198,11 +2186,6 @@ query myQuery($shouldStream: Boolean) {
21982186
[related note](#note-088b7)). When `false`, the field will not be streamed and
21992187
all list items will be included in the initial response. Defaults to `true`
22002188
when omitted.
2201-
- `label: String` - May be used by GraphQL clients to identify the data from
2202-
responses and associate it with the corresponding stream directive. If
2203-
provided, the GraphQL service must add it to the corresponding payload.
2204-
`label` must be unique label across all `@defer` and `@stream` directives in a
2205-
document. `label` must not be provided as a variable.
22062189
- `initialCount: Int` - The number of list items the service should return as
22072190
part of the initial response. If omitted, defaults to `0`. A field error will
22082191
be raised if the value of this argument is less than `0`.

spec/Section 5 -- Validation.md

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,71 +1605,6 @@ subscription sub {
16051605
}
16061606
```
16071607

1608-
### Defer And Stream Directive Labels Are Unique
1609-
1610-
** Formal Specification **
1611-
1612-
- Let {labelValues} be an empty set.
1613-
- For every {directive} in the document:
1614-
- Let {directiveName} be the name of {directive}.
1615-
- If {directiveName} is "defer" or "stream":
1616-
- For every {argument} in {directive}:
1617-
- Let {argumentName} be the name of {argument}.
1618-
- Let {argumentValue} be the value passed to {argument}.
1619-
- If {argumentName} is "label":
1620-
- {argumentValue} must not be a variable.
1621-
- {argumentValue} must not be present in {labelValues}.
1622-
- Append {argumentValue} to {labelValues}.
1623-
1624-
**Explanatory Text**
1625-
1626-
The `@defer` and `@stream` directives each accept an argument "label". This
1627-
label may be used by GraphQL clients to uniquely identify response payloads. If
1628-
a label is passed, it must not be a variable and it must be unique within all
1629-
other `@defer` and `@stream` directives in the document.
1630-
1631-
For example the following document is valid:
1632-
1633-
```graphql example
1634-
{
1635-
dog {
1636-
...fragmentOne
1637-
...fragmentTwo @defer(label: "dogDefer")
1638-
}
1639-
pets @stream(label: "petStream") {
1640-
name
1641-
}
1642-
}
1643-
1644-
fragment fragmentOne on Dog {
1645-
name
1646-
}
1647-
1648-
fragment fragmentTwo on Dog {
1649-
owner {
1650-
name
1651-
}
1652-
}
1653-
```
1654-
1655-
For example, the following document will not pass validation because the same
1656-
label is used in different `@defer` and `@stream` directives.:
1657-
1658-
```raw graphql counter-example
1659-
{
1660-
dog {
1661-
...fragmentOne @defer(label: "MyLabel")
1662-
}
1663-
pets @stream(label: "MyLabel") {
1664-
name
1665-
}
1666-
}
1667-
1668-
fragment fragmentOne on Dog {
1669-
name
1670-
}
1671-
```
1672-
16731608
### Stream Directives Are Used On List Fields
16741609

16751610
**Formal Specification**

spec/Section 6 -- Execution.md

Lines changed: 23 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,8 @@ objectValue, variableValues, path, subsequentPayloads, asyncRecord):
430430
- Let {responseValue} be {ExecuteField(objectType, objectValue, fieldType,
431431
fields, variableValues, path, subsequentPayloads, asyncRecord)}.
432432
- Set {responseValue} as the value for {responseKey} in {resultMap}.
433-
- For each {deferredGroupFieldSet} and {label} in {deferredGroupedFieldsList}
434-
- Call {ExecuteDeferredFragment(label, objectType, objectValue,
433+
- For each {deferredGroupFieldSet} in {deferredGroupedFieldsList}
434+
- Call {ExecuteDeferredFragment(objectType, objectValue,
435435
deferredGroupFieldSet, path, variableValues, asyncRecord,
436436
subsequentPayloads)}
437437
- Return {resultMap}.
@@ -695,13 +695,10 @@ visitedFragments, deferredGroupedFieldsList):
695695
with the next {selection} in {selectionSet}.
696696
- Let {fragmentSelectionSet} be the top-level selection set of {fragment}.
697697
- If {deferDirective} is defined:
698-
- Let {label} be the value or the variable to {deferDirective}'s {label}
699-
argument.
700698
- Let {deferredGroupedFields} be the result of calling
701-
{CollectFields(objectType, fragmentSelectionSet, variableValues, path,
702-
asyncRecord, visitedFragments, deferredGroupedFieldsList)}.
703-
- Append a record containing {label} and {deferredGroupedFields} to
704-
{deferredGroupedFieldsList}.
699+
{CollectFields(objectType, fragmentSelectionSet, variableValues,
700+
visitedFragments, deferredGroupedFieldsList)}.
701+
- Append {deferredGroupedFields} to {deferredGroupedFieldsList}.
705702
- Continue with the next {selection} in {selectionSet}.
706703
- Let {fragmentGroupedFieldSet} be the result of calling
707704
{CollectFields(objectType, fragmentSelectionSet, variableValues, path,
@@ -725,13 +722,10 @@ visitedFragments, deferredGroupedFieldsList):
725722
- If this execution is for a subscription operation, raise a _field
726723
error_.
727724
- If {deferDirective} is defined:
728-
- Let {label} be the value or the variable to {deferDirective}'s {label}
729-
argument.
730725
- Let {deferredGroupedFields} be the result of calling
731-
{CollectFields(objectType, fragmentSelectionSet, variableValues, path,
732-
asyncRecord, visitedFragments, deferredGroupedFieldsList)}.
733-
- Append a record containing {label} and {deferredGroupedFields} to
734-
{deferredGroupedFieldsList}.
726+
{CollectFields(objectType, fragmentSelectionSet, variableValues,
727+
visitedFragments, deferredGroupedFieldsList)}.
728+
- Append {deferredGroupedFields} to {deferredGroupedFieldsList}.
735729
- Continue with the next {selection} in {selectionSet}.
736730
- Let {fragmentGroupedFieldSet} be the result of calling
737731
{CollectFields(objectType, fragmentSelectionSet, variableValues, path,
@@ -764,7 +758,6 @@ DoesFragmentTypeApply(objectType, fragmentType):
764758
An Async Payload Record is either a Deferred Fragment Record or a Stream Record.
765759
All Async Payload Records are structures containing:
766760

767-
- {label}: value derived from the corresponding `@defer` or `@stream` directive.
768761
- {path}: a list of field names and indices from root to the location of the
769762
corresponding `@defer` or `@stream` directive.
770763
- {iterator}: The underlying iterator if created from a `@stream` directive.
@@ -776,10 +769,10 @@ All Async Payload Records are structures containing:
776769

777770
#### Execute Deferred Fragment
778771

779-
ExecuteDeferredFragment(label, objectType, objectValue, groupedFieldSet, path,
772+
ExecuteDeferredFragment(objectType, objectValue, groupedFieldSet, path,
780773
variableValues, parentRecord, subsequentPayloads):
781774

782-
- Let {deferRecord} be an async payload record created from {label} and {path}.
775+
- Let {deferRecord} be an async payload record created from {path}.
783776
- Initialize {errors} on {deferRecord} to an empty list.
784777
- Let {dataExecution} be the asynchronous future value of:
785778
- Let {payload} be an unordered map.
@@ -803,8 +796,6 @@ variableValues, parentRecord, subsequentPayloads):
803796
- Add an entry to {payload} named `data` with the value {null}.
804797
- Otherwise:
805798
- Add an entry to {payload} named `data` with the value {resultMap}.
806-
- If {label} is defined:
807-
- Add an entry to {payload} named `label` with the value {label}.
808799
- Add an entry to {payload} named `path` with the value {path}.
809800
- Return {payload}.
810801
- Set {dataExecution} on {deferredFragmentRecord}.
@@ -965,11 +956,11 @@ yielded items satisfies `initialCount` specified on the `@stream` directive.
965956

966957
#### Execute Stream Field
967958

968-
ExecuteStreamField(label, iterator, index, fields, innerType, path,
969-
parentRecord, variableValues, subsequentPayloads):
959+
ExecuteStreamField(iterator, index, fields, innerType, path, parentRecord,
960+
variableValues, subsequentPayloads):
970961

971-
- Let {streamRecord} be an async payload record created from {label}, {path},
972-
and {iterator}.
962+
- Let {streamRecord} be an async payload record created from {path}, and
963+
{iterator}.
973964
- Initialize {errors} on {streamRecord} to an empty list.
974965
- Let {itemPath} be {path} with {index} appended.
975966
- Let {dataExecution} be the asynchronous future value of:
@@ -987,7 +978,7 @@ parentRecord, variableValues, subsequentPayloads):
987978
item, variableValues, itemPath, subsequentPayloads, parentRecord)}.
988979
- Append any encountered field errors to {errors}.
989980
- Increment {index}.
990-
- Call {ExecuteStreamField(label, iterator, index, fields, innerType, path,
981+
- Call {ExecuteStreamField(iterator, index, fields, innerType, path,
991982
streamRecord, variableValues, subsequentPayloads)}.
992983
- If a field error was raised, causing a {null} to be propagated to {data},
993984
and {innerType} is a Non-Nullable type:
@@ -997,8 +988,6 @@ parentRecord, variableValues, subsequentPayloads):
997988
{data}.
998989
- If {errors} is not empty:
999990
- Add an entry to {payload} named `errors` with the value {errors}.
1000-
- If {label} is defined:
1001-
- Add an entry to {payload} named `label` with the value {label}.
1002991
- Add an entry to {payload} named `path` with the value {itemPath}.
1003992
- If {parentRecord} is defined:
1004993
- Wait for the result of {dataExecution} on {parentRecord}.
@@ -1030,16 +1019,14 @@ subsequentPayloads, asyncRecord):
10301019
- Let {initialCount} be the value or variable provided to
10311020
{streamDirective}'s {initialCount} argument.
10321021
- If {initialCount} is less than zero, raise a _field error_.
1033-
- Let {label} be the value or variable provided to {streamDirective}'s
1034-
{label} argument.
10351022
- Let {iterator} be an iterator for {result}.
10361023
- Let {items} be an empty list.
10371024
- Let {index} be zero.
10381025
- While {result} is not closed:
10391026
- If {streamDirective} is defined and {index} is greater than or equal to
10401027
{initialCount}:
1041-
- Call {ExecuteStreamField(label, iterator, index, fields, innerType,
1042-
path, asyncRecord, subsequentPayloads)}.
1028+
- Call {ExecuteStreamField(iterator, index, fields, innerType, path,
1029+
asyncRecord, subsequentPayloads)}.
10431030
- Return {items}.
10441031
- Otherwise:
10451032
- Wait for the next item from {result} via the {iterator}.
@@ -1179,10 +1166,10 @@ error:
11791166
```graphql example
11801167
{
11811168
birthday {
1182-
... @defer(label: "monthDefer") {
1169+
... @defer {
11831170
month
11841171
}
1185-
... @defer(label: "yearDefer") {
1172+
... @defer {
11861173
year
11871174
}
11881175
}
@@ -1198,32 +1185,29 @@ Response 1, the initial response is sent:
11981185
}
11991186
```
12001187

1201-
Response 2, the defer payload for label "monthDefer" is sent. The {data} entry
1202-
has been set to {null}, as this {null} as propagated as high as the error
1203-
boundary will allow.
1188+
Response 2, a defer payload is sent. The {data} entry has been set to {null}, as
1189+
this {null} as propagated as high as the error boundary will allow.
12041190

12051191
```json example
12061192
{
12071193
"incremental": [
12081194
{
12091195
"path": ["birthday"],
1210-
"label": "monthDefer",
12111196
"data": null
12121197
}
12131198
],
12141199
"hasNext": false
12151200
}
12161201
```
12171202

1218-
Response 3, the defer payload for label "yearDefer" is sent. The data in this
1219-
payload is unaffected by the previous null error.
1203+
Response 3, another defer payload is sent. The data in this payload is
1204+
unaffected by the previous null error.
12201205

12211206
```json example
12221207
{
12231208
"incremental": [
12241209
{
12251210
"path": ["birthday"],
1226-
"label": "yearDefer",
12271211
"data": { "year": "2022" }
12281212
}
12291213
],

spec/Section 7 -- Response.md

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,10 @@ When the response of the GraphQL operation is a response stream, the first value
2626
will be the initial response. All subsequent values may contain an `incremental`
2727
entry, containing a list of Defer or Stream payloads.
2828

29-
The `label` and `path` entries on Defer and Stream payloads are used by clients
30-
to identify the `@defer` or `@stream` directive from the GraphQL operation that
31-
triggered this response to be included in an `incremental` entry on a value
32-
returned by the response stream. When a label is provided, the combination of
33-
these two entries will be unique across all Defer and Stream payloads returned
34-
in the response stream.
29+
The `path` entries on Defer and Stream payloads are used by clients to identify
30+
the `@defer` or `@stream` directive from the GraphQL operation that triggered
31+
this response to be included in an `incremental` entry on a value returned by
32+
the response stream.
3533

3634
If the response of the GraphQL operation is a response stream, each response map
3735
must contain an entry with key `hasNext`. The value of this entry is `true` for
@@ -275,9 +273,9 @@ For example, a query containing both defer and stream:
275273
```graphql example
276274
query {
277275
person(id: "cGVvcGxlOjE=") {
278-
...HomeWorldFragment @defer(label: "homeWorldDefer")
276+
...HomeWorldFragment @defer
279277
name
280-
films @stream(initialCount: 1, label: "filmsStream") {
278+
films @stream(initialCount: 1) {
281279
title
282280
}
283281
}
@@ -312,12 +310,10 @@ Response 2, contains the defer payload and the first stream payload.
312310
{
313311
"incremental": [
314312
{
315-
"label": "homeWorldDefer",
316313
"path": ["person"],
317314
"data": { "homeWorld": { "name": "Tatooine" } }
318315
},
319316
{
320-
"label": "filmsStream",
321317
"path": ["person", "films", 1],
322318
"items": [{ "title": "The Empire Strikes Back" }]
323319
}
@@ -335,7 +331,6 @@ would be the final response.
335331
{
336332
"incremental": [
337333
{
338-
"label": "filmsStream",
339334
"path": ["person", "films", 2],
340335
"items": [{ "title": "Return of the Jedi" }]
341336
}
@@ -359,7 +354,7 @@ iterator of the `films` field closes.
359354
A stream payload is a map that may appear as an item in the `incremental` entry
360355
of a response. A stream payload is the result of an associated `@stream`
361356
directive in the operation. A stream payload must contain `items` and `path`
362-
entries and may contain `label`, `errors`, and `extensions` entries.
357+
entries and may contain `errors` and `extensions` entries.
363358

364359
##### Items
365360

@@ -374,7 +369,7 @@ than the list field with the associated `@stream` directive.
374369
A defer payload is a map that may appear as an item in the `incremental` entry
375370
of a response. A defer payload is the result of an associated `@defer` directive
376371
in the operation. A defer payload must contain `data` and `path` entries and may
377-
contain `label`, `errors`, and `extensions` entries.
372+
contain `errors` and `extensions` entries.
378373

379374
##### Data
380375

@@ -411,14 +406,6 @@ of the field containing the associated `@defer` directive.
411406
When the `path` field is present on an "Error result", it indicates the response
412407
field which experienced the error.
413408

414-
#### Label
415-
416-
Stream and Defer payloads may contain a string field `label`. This `label` is
417-
the same label passed to the `@defer` or `@stream` directive associated with the
418-
response. This allows clients to identify which `@defer` or `@stream` directive
419-
is associated with this value. `label` will not be present if the corresponding
420-
`@defer` or `@stream` directive is not passed a `label` argument.
421-
422409
## Serialization Format
423410

424411
GraphQL does not require a specific serialization format. However, clients

0 commit comments

Comments
 (0)