Skip to content

Commit 3822c97

Browse files
committed
formatting
1 parent 06819e3 commit 3822c97

File tree

5 files changed

+116
-101
lines changed

5 files changed

+116
-101
lines changed

spec/Appendix B -- Grammar Summary.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,9 @@ Field : Alias? Name Arguments? Nullability? Directives? SelectionSet?
161161
Alias : Name :
162162

163163
Nullability :
164-
- !
165-
- ?
164+
165+
- !
166+
- ?
166167

167168
Arguments[Const] : ( Argument[?Const]+ )
168169

spec/Section 2 -- Language.md

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -518,25 +518,29 @@ which returns the result:
518518
## Nullability
519519

520520
Nullability :
521-
- ListNullability NullabilityModifier?
522-
- NullabilityModifier
521+
522+
- ListNullability NullabilityModifier?
523+
- NullabilityModifier
523524

524525
ListNullability : `[` Nullability? `]`
525526

526527
NullabilityModifier :
527-
- `!`
528-
- `?`
529528

530-
Fields can have their nullability designated with either a `!` to indicate that a
531-
field should be `Non-Nullable` or a `?` to indicate that a field should be
532-
`Nullable`. These designators override the nullability set on a field by the schema
533-
for the operation where they're being used. In addition to being `Non-Nullable`,
534-
if a field marked with `!` resolves to `null`, it propagates to the nearest parent
535-
field marked with a `?` or to `data` if one does not exist. An error is added to
536-
the `errors` array identical to if the field had been `Non-Nullable` in the schema.
529+
- `!`
530+
- `?`
531+
532+
Fields can have their nullability designated with either a `!` to indicate that
533+
a field should be `Non-Nullable` or a `?` to indicate that a field should be
534+
`Nullable`. These designators override the nullability set on a field by the
535+
schema for the operation where they're being used. In addition to being
536+
`Non-Nullable`, if a field marked with `!` resolves to `null`, it propagates to
537+
the nearest parent field marked with a `?` or to `data` if one does not exist.
538+
An error is added to the `errors` array identical to if the field had been
539+
`Non-Nullable` in the schema.
537540

538-
In this example, we can indicate that a `user`'s `name` that could possibly be
539-
`null`, should not be `null` and that `null` propagation should halt at the `user` field:
541+
In this example, we can indicate that a `user`'s `name` that could possibly be
542+
`null`, should not be `null` and that `null` propagation should halt at the
543+
`user` field:
540544

541545
```graphql example
542546
{
@@ -547,7 +551,7 @@ In this example, we can indicate that a `user`'s `name` that could possibly be
547551
}
548552
```
549553

550-
If `name` comes back non-`null`, then the return value is the same as if the
554+
If `name` comes back non-`null`, then the return value is the same as if the
551555
nullability designator was not used:
552556

553557
```json example
@@ -559,9 +563,9 @@ nullability designator was not used:
559563
}
560564
```
561565

562-
In the event that `name` is `null`, the field's parent selection set becomes `null`
563-
in the result and an error is returned, just as if `name` was marked `Non-Nullable`
564-
in the schema:
566+
In the event that `name` is `null`, the field's parent selection set becomes
567+
`null` in the result and an error is returned, just as if `name` was marked
568+
`Non-Nullable` in the schema:
565569

566570
```json example
567571
{
@@ -572,15 +576,15 @@ in the schema:
572576
{
573577
"locations": [{ "column": 13, "line": 4 }],
574578
"message": "Cannot return null for non-nullable field User.name.",
575-
"path": ["user", "name"],
576-
},
579+
"path": ["user", "name"]
580+
}
577581
]
578582
}
579583
```
580584

581-
If `user` was `Non-Nullable` in the schema, but we don't want `null`s propagating
582-
past that point, then we can use `?` to create null propagation boundary. `User` will be
583-
treated as `Nullable` for this operation:
585+
If `user` was `Non-Nullable` in the schema, but we don't want `null`s
586+
propagating past that point, then we can use `?` to create null propagation
587+
boundary. `User` will be treated as `Nullable` for this operation:
584588

585589
```graphql example
586590
{
@@ -602,23 +606,23 @@ Nullability designators can also be applied to list elements like so.
602606
}
603607
```
604608

605-
In the above example, the query author is saying that each individual pet name should be
606-
`Non-Nullable`, but the list as a whole should be `Nullable`. The same syntax can be
607-
applied to multidimensional lists.
609+
In the above example, the query author is saying that each individual pet name
610+
should be `Non-Nullable`, but the list as a whole should be `Nullable`. The same
611+
syntax can be applied to multidimensional lists.
608612

609613
```graphql example
610614
{
611615
threeDimensionalMatrix[[[?]!]]!
612616
}
613617
```
614618

615-
Any element without a nullability designator will inherit its nullability from the
616-
schema definition, exactly the same as non-list fields do. When designating
617-
nullability for list fields, query authors can either use a single designator (`!` or `?`)
618-
to designate the nullability of the entire field, or they can use the list element
619-
nullability syntax displayed above. The number of dimensions indicated by
620-
list element nullability syntax is required to match the number of dimensions of the field.
621-
Anything else results in a query validation error.
619+
Any element without a nullability designator will inherit its nullability from
620+
the schema definition, exactly the same as non-list fields do. When designating
621+
nullability for list fields, query authors can either use a single designator
622+
(`!` or `?`) to designate the nullability of the entire field, or they can use
623+
the list element nullability syntax displayed above. The number of dimensions
624+
indicated by list element nullability syntax is required to match the number of
625+
dimensions of the field. Anything else results in a query validation error.
622626

623627
## Fragments
624628

spec/Section 5 -- Validation.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -564,9 +564,9 @@ fragment conflictingDifferingResponses on Pet {
564564
}
565565
```
566566

567-
The same is true if a field is designated `Non-Nullable` in an operation. In this
568-
case, `someValue` could be either a `String` or a `String!` which are two different
569-
types and therefore can not be merged:
567+
The same is true if a field is designated `Non-Nullable` in an operation. In
568+
this case, `someValue` could be either a `String` or a `String!` which are two
569+
different types and therefore can not be merged:
570570

571571
```graphql counter-example
572572
fragment conflictingDifferingResponses on Pet {
@@ -587,18 +587,21 @@ fragment conflictingDifferingResponses on Pet {
587587
- Let {fieldDef} be the definition of {field}
588588
- Let {fieldType} be the type of {fieldDef}
589589
- Let {requiredStatus} be the required status of {field}
590-
- Let {designatorDepth} be the number of square bracket pairs in {requiredStatus}
590+
- Let {designatorDepth} be the number of square bracket pairs in
591+
{requiredStatus}
591592
- Let {typeDepth} be the number of list dimensions in {fieldType}
592-
- If {typeDepth} equals {designatorDepth} or {designatorDepth} equals 0 return true
593+
- If {typeDepth} equals {designatorDepth} or {designatorDepth} equals 0 return
594+
true
593595
- Otherwise return false
594596

595597
**Explanatory Text**
596598

597-
List fields can be marked with nullability designators that look like `[?]!` to indicate the
598-
nullability of the list's elements and the nullability of the list itself. For multi-dimensional
599-
lists, the designator would look something like `[[[!]?]]!`. If the designator is not a simple `!` or `?`, then the number of dimensions of the
600-
designator are required to match the number of dimensions of the field's type. If the two do not
601-
match then a validation error is thrown.
599+
List fields can be marked with nullability designators that look like `[?]!` to
600+
indicate the nullability of the list's elements and the nullability of the list
601+
itself. For multi-dimensional lists, the designator would look something like
602+
`[[[!]?]]!`. If the designator is not a simple `!` or `?`, then the number of
603+
dimensions of the designator are required to match the number of dimensions of
604+
the field's type. If the two do not match then a validation error is thrown.
602605

603606
### Leaf Field Selections
604607

spec/Section 6 -- Execution.md

Lines changed: 60 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -568,63 +568,70 @@ set or coercing a scalar value.
568568

569569
ExecuteField(objectType, objectValue, fieldType, fields, variableValues):
570570

571-
- Let {field} be the first entry in {fields}.
572-
- Let {fieldName} be the field name of {field}.
573-
- Let {requiredStatus} be the required status of {field}.
574-
- Let {argumentValues} be the result of {CoerceArgumentValues(objectType, field, variableValues)}
575-
- Let {resolvedValue} be {ResolveFieldValue(objectType, objectValue, fieldName, argumentValues)}.
576-
- Let {modifiedFieldType} be {ModifiedOutputType(fieldType, requiredStatus)}.
577-
- Return the result of {CompleteValue(modifiedFieldType, fields, resolvedValue, variableValues)}.
571+
- Let {field} be the first entry in {fields}.
572+
- Let {fieldName} be the field name of {field}.
573+
- Let {requiredStatus} be the required status of {field}.
574+
- Let {argumentValues} be the result of {CoerceArgumentValues(objectType, field,
575+
variableValues)}
576+
- Let {resolvedValue} be {ResolveFieldValue(objectType, objectValue, fieldName,
577+
argumentValues)}.
578+
- Let {modifiedFieldType} be {ModifiedOutputType(fieldType, requiredStatus)}.
579+
- Return the result of {CompleteValue(modifiedFieldType, fields, resolvedValue,
580+
variableValues)}.
578581

579582
## Accounting For Client Controlled Nullability Designators
580583

581-
A field can have its nullability status set either in its service's schema, or
582-
a nullability designator (! or ?) can override it for the duration of an execution.
583-
In order to determine a field's true nullability, both are taken into account
584-
and a final type is produced.
584+
A field can have its nullability status set either in its service's schema, or a
585+
nullability designator (! or ?) can override it for the duration of an
586+
execution. In order to determine a field's true nullability, both are taken into
587+
account and a final type is produced.
585588

586589
ModifiedOutputType(outputType, requiredStatus):
587590

588-
- Create a {stack} initially containing {type}.
589-
- As long as the top of {stack} is a list:
590-
- Let {currentType} be the top item of {stack}.
591-
- Push the {elementType} of {currentType} to the {stack}.
592-
- If {requiredStatus} exists:
593-
- Start visiting {node}s in {requiredStatus} and building up a {resultingType}:
594-
- For each {node} that is a RequiredDesignator:
595-
- If {resultingType} exists:
596-
- Let {nullableResult} be the nullable type of {resultingType}.
597-
- Set {resultingType} to the Non-Nullable type of {nullableResult}.
598-
- Continue onto the next node.
599-
- Pop the top of {stack} and let {nextType} be the result.
600-
- Let {nullableType} be the nullable type of {nextType}.
601-
- Set {resultingType} to the Non-Nullable type of {nullableType}.
591+
- Create a {stack} initially containing {type}.
592+
- As long as the top of {stack} is a list:
593+
- Let {currentType} be the top item of {stack}.
594+
- Push the {elementType} of {currentType} to the {stack}.
595+
- If {requiredStatus} exists:
596+
- Start visiting {node}s in {requiredStatus} and building up a
597+
{resultingType}:
598+
- For each {node} that is a RequiredDesignator:
599+
- If {resultingType} exists:
600+
- Let {nullableResult} be the nullable type of {resultingType}.
601+
- Set {resultingType} to the Non-Nullable type of {nullableResult}.
602602
- Continue onto the next node.
603-
- For each {node} that is a OptionalDesignator:
604-
- If {resultingType} exists:
605-
- Set {resultingType} to the nullableType type of {resultingType}.
606-
- Continue onto the next node.
607-
- Pop the top of {stack} and let {nextType} be the result.
608-
- Set {resultingType} to the nullable type of {resultingType}
603+
- Pop the top of {stack} and let {nextType} be the result.
604+
- Let {nullableType} be the nullable type of {nextType}.
605+
- Set {resultingType} to the Non-Nullable type of {nullableType}.
606+
- Continue onto the next node.
607+
- For each {node} that is a OptionalDesignator:
608+
- If {resultingType} exists:
609+
- Set {resultingType} to the nullableType type of {resultingType}.
609610
- Continue onto the next node.
610-
- For each {node} that is a ListNullabilityDesignator:
611-
- Pop the top of {stack} and let {listType} be the result
612-
- If the nullable type of {listType} is not a list
613-
- Pop the top of {stack} and set {listType} to the result
614-
- If {listType} does not exist:
615-
- Throw an error because {requiredStatus} had more list dimensions than {outputType} and is invalid.
616-
- If {resultingType} exist:
617-
- If {listType} is Non-Nullable:
618-
- Set {resultingType} to a Non-Nullable list where the element is {resultingType}.
619-
- Otherwise:
620-
- Set {resultingType} to a list where the element is {resultingType}.
621-
- Continue onto the next node.
622-
- Set {resultingType} to {listType}
623-
- If {stack} is not empty:
624-
- Throw an error because {requiredStatus} had fewer list dimensions than {outputType} and is invalid.
625-
- Return {resultingType}.
626-
- Otherwise:
627-
- Return {outputType}.
611+
- Pop the top of {stack} and let {nextType} be the result.
612+
- Set {resultingType} to the nullable type of {resultingType}
613+
- Continue onto the next node.
614+
- For each {node} that is a ListNullabilityDesignator:
615+
- Pop the top of {stack} and let {listType} be the result
616+
- If the nullable type of {listType} is not a list
617+
- Pop the top of {stack} and set {listType} to the result
618+
- If {listType} does not exist:
619+
- Throw an error because {requiredStatus} had more list dimensions than
620+
{outputType} and is invalid.
621+
- If {resultingType} exist:
622+
- If {listType} is Non-Nullable:
623+
- Set {resultingType} to a Non-Nullable list where the element is
624+
{resultingType}.
625+
- Otherwise:
626+
- Set {resultingType} to a list where the element is {resultingType}.
627+
- Continue onto the next node.
628+
- Set {resultingType} to {listType}
629+
- If {stack} is not empty:
630+
- Throw an error because {requiredStatus} had fewer list dimensions than
631+
{outputType} and is invalid.
632+
- Return {resultingType}.
633+
- Otherwise:
634+
- Return {outputType}.
628635

629636
### Coercing Field Arguments
630637

@@ -827,9 +834,9 @@ field returned {null}, and the error must be added to the {"errors"} list in the
827834
response.
828835

829836
If the result of resolving a field is {null} (either because the function to
830-
resolve the field returned {null} or because a field error was raised), and
831-
the {ModifiedOutputType} of that field is of a `Non-Null` type, then a field
832-
error is raised. The error must be added to the {"errors"} list in the response.
837+
resolve the field returned {null} or because a field error was raised), and the
838+
{ModifiedOutputType} of that field is of a `Non-Null` type, then a field error
839+
is raised. The error must be added to the {"errors"} list in the response.
833840

834841
If the field returns {null} because of a field error which has already been
835842
added to the {"errors"} list in the response, the {"errors"} list must not be
@@ -838,7 +845,7 @@ field.
838845

839846
Since `Non-Null` type fields cannot be {null}, field errors are propagated to be
840847
handled by the parent field. If the parent field may be {null} then it resolves
841-
to {null}, otherwise if its {ModifiedOutputType} is a `Non-Null` type, the field
848+
to {null}, otherwise if its {ModifiedOutputType} is a `Non-Null` type, the field
842849
error is further propagated to its parent field.
843850

844851
If a `List` type wraps a `Non-Null` type, and one of the elements of that list

spec/Section 7 -- Response.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,10 @@ The response might look like:
161161
```
162162

163163
If the field which experienced an error was declared as `Non-Null` or designated
164-
`Non-Null` in the query document, the `null` result will propagate to the
165-
next nullable field. In that case, the `path` for the error should include
166-
the full path to the result field where the error was raised, even if that
167-
field is not present in the response.
164+
`Non-Null` in the query document, the `null` result will propagate to the next
165+
nullable field. In that case, the `path` for the error should include the full
166+
path to the result field where the error was raised, even if that field is not
167+
present in the response.
168168

169169
For example, if the `name` field from above had declared a `Non-Null` return
170170
type in the schema, the result would look different but the error reported would

0 commit comments

Comments
 (0)