Skip to content

Commit 1cbad5d

Browse files
committed
Use :: syntax for enum values
1 parent 87f6bd0 commit 1cbad5d

File tree

3 files changed

+49
-19
lines changed

3 files changed

+49
-19
lines changed

spec/Appendix B -- Grammar Summary.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,15 @@ Token ::
4545

4646
Punctuator ::
4747

48+
- ColonPunctuator
4849
- DotPunctuator
4950
- OtherPunctuator
5051

52+
ColonPunctuator :: `:` [lookahead != {`:`}]
53+
5154
DotPunctuator :: `.` [lookahead != {`.`, Digit}]
5255

53-
OtherPunctuator :: one of ! $ & ( ) ... : = @ [ ] { | }
56+
OtherPunctuator :: one of ! $ & ( ) ... :: = @ [ ] { | }
5457

5558
Name ::
5659

@@ -423,17 +426,20 @@ TypeSystemDirectiveLocation : one of
423426
SchemaCoordinate :
424427

425428
- TypeCoordinate
426-
- MemberCoordinate
429+
- FieldCoordinate
427430
- ArgumentCoordinate
431+
- ValueCoordinate
428432
- DirectiveCoordinate
429433
- DirectiveArgumentCoordinate
430434

431435
TypeCoordinate : Name
432436

433-
MemberCoordinate : Name . Name
437+
FieldCoordinate : Name . Name
434438

435439
ArgumentCoordinate : Name . Name ( Name : )
436440

441+
ValueCoordinate : Name :: Name
442+
437443
DirectiveCoordinate : @ Name
438444

439445
DirectiveArgumentCoordinate : @ Name ( Name : )

spec/Section 2 -- Language.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,23 @@ and is {Ignored}.
178178

179179
Punctuator ::
180180

181+
- ColonPunctuator
181182
- DotPunctuator
182183
- OtherPunctuator
183184

185+
ColonPunctuator :: `:` [lookahead != {`:`}]
186+
184187
DotPunctuator :: `.` [lookahead != {`.`, Digit}]
185188

186-
OtherPunctuator :: one of ! $ & ( ) ... : = @ [ ] { | }
189+
OtherPunctuator :: one of ! $ & ( ) ... :: = @ [ ] { | }
187190

188191
GraphQL documents include punctuation in order to describe structure. GraphQL is
189192
a data description language and not a programming language, therefore GraphQL
190193
lacks the punctuation often used to describe mathematical expressions.
191194

195+
The {`:`} punctuator must not be followed by a {`:`}. This ensures that the
196+
source {"::"} can only be interpreted as a single {`::`} and not two {`:`}.
197+
192198
The {`.`} punctuator must not be followed by a {`.`} or {Digit}. This ensures
193199
that the source {"..."} can only be interpreted as a single {`...`} and not
194200
three {`.`}. It also avoids any potential ambiguity with {FloatValue}. As an

spec/Section 3 -- Type System.md

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2174,17 +2174,20 @@ scalar UUID @specifiedBy(url: "https://tools.ietf.org/html/rfc4122")
21742174
SchemaCoordinate :
21752175

21762176
- TypeCoordinate
2177-
- MemberCoordinate
2177+
- FieldCoordinate
21782178
- ArgumentCoordinate
2179+
- ValueCoordinate
21792180
- DirectiveCoordinate
21802181
- DirectiveArgumentCoordinate
21812182

21822183
TypeCoordinate : Name
21832184

2184-
MemberCoordinate : Name . Name
2185+
FieldCoordinate : Name . Name
21852186

21862187
ArgumentCoordinate : Name . Name ( Name : )
21872188

2189+
ValueCoordinate : Name :: Name
2190+
21882191
DirectiveCoordinate : @ Name
21892192

21902193
DirectiveArgumentCoordinate : @ Name ( Name : )
@@ -2195,6 +2198,16 @@ _schema element_ within a GraphQL Schema.
21952198
:: A _schema element_ can be a named type, a field, an input field, an enum
21962199
value, a field argument, a directive, or a directive argument.
21972200

2201+
:: The _containing element_ of a _schema element_ is the schema element with one
2202+
fewer {Name} token that syntactically contains it. For example:
2203+
2204+
- The containing element of an {ArgumentCoordinate} or
2205+
{DirectiveArgumentCoordinate} is the corresponding {FieldCoordinate} or
2206+
{DirectiveCoordinate} respectively.
2207+
- The containing element of a {FieldCoordinate} or {ValueCoordinate} is its
2208+
containing {TypeCoordinate}.
2209+
- {TypeCoordinate} and {DirectiveCoordinate} have no containing element.
2210+
21982211
A _schema coordinate_ is always unique. Each _schema element_ can be referenced
21992212
by exactly one possible schema coordinate.
22002213

@@ -2220,31 +2233,27 @@ production.
22202233
To refer to a _schema element_, a _schema coordinate_ must be interpreted in the
22212234
context of a GraphQL {schema}.
22222235

2223-
If the _schema element_ cannot be found, the resolve function will not yield a
2224-
value (without raising an error). However, an error will be raised if any
2225-
non-leaf nodes within a _schema coordinate_ cannot be found in the {schema}.
2236+
If the _schema element_ cannot be found, and either it has no _containing
2237+
element_ or its _containing element_ exists and is of the expected type, the
2238+
resolve function returns {null}. Otherwise, an error is raised.
22262239

22272240
TypeCoordinate : Name
22282241

22292242
1. Let {typeName} be the value of {Name}.
22302243
2. Return the type in the {schema} named {typeName}, or {null} if no such type
22312244
exists.
22322245

2233-
MemberCoordinate : Name . Name
2246+
FieldCoordinate : Name . Name
22342247

22352248
1. Let {typeName} be the value of the first {Name}.
22362249
2. Let {type} be the type in the {schema} named {typeName}.
2237-
3. Assert: {type} must exist, and must be an Enum, Input Object, Object or
2238-
Interface type.
2239-
4. If {type} is an Enum type:
2240-
1. Let {enumValueName} be the value of the second {Name}.
2241-
2. Return the enum value of {type} named {enumValueName}, or {null} if no
2242-
such value exists.
2243-
5. Otherwise, if {type} is an Input Object type:
2250+
3. Assert: {type} must exist, and must be an Input Object, Object or Interface
2251+
type.
2252+
4. If {type} is an Input Object type:
22442253
1. Let {inputFieldName} be the value of the second {Name}.
22452254
2. Return the input field of {type} named {inputFieldName}, or {null} if no
22462255
such input field exists.
2247-
6. Otherwise:
2256+
5. Otherwise:
22482257
1. Let {fieldName} be the value of the second {Name}.
22492258
2. Return the field of {type} named {fieldName}, or {null} if no such field
22502259
exists.
@@ -2261,6 +2270,15 @@ ArgumentCoordinate : Name . Name ( Name : )
22612270
8. Return the argument of {field} named {fieldArgumentName}, or {null} if no
22622271
such argument exists.
22632272

2273+
ValueCoordinate : Name :: Name
2274+
2275+
1. Let {typeName} be the value of the first {Name}.
2276+
2. Let {type} be the type in the {schema} named {typeName}.
2277+
3. Assert: {type} must exist, and must be an Enum type.
2278+
4. Let {enumValueName} be the value of the second {Name}.
2279+
5. Return the enum value of {type} named {enumValueName}, or {null} if no such
2280+
value exists.
2281+
22642282
DirectiveCoordinate : @ Name
22652283

22662284
1. Let {directiveName} be the value of {Name}.
@@ -2283,8 +2301,8 @@ DirectiveArgumentCoordinate : @ Name ( Name : )
22832301
| Named Type | `Business` | `Business` type |
22842302
| Field | `Business.name` | `name` field on the `Business` type |
22852303
| Input Field | `SearchCriteria.filter` | `filter` input field on the `SearchCriteria` input object type |
2286-
| Enum Value | `SearchFilter.OPEN_NOW` | `OPEN_NOW` value of the `SearchFilter` enum |
22872304
| Field Argument | `Query.searchBusiness(criteria:)` | `criteria` argument on the `searchBusiness` field on the `Query` type |
2305+
| Enum Value | `SearchFilter::OPEN_NOW` | `OPEN_NOW` value of the `SearchFilter` enum |
22882306
| Directive | `@private` | `@private` directive |
22892307
| Directive Argument | `@private(scope:)` | `scope` argument on the `@private` directive |
22902308

0 commit comments

Comments
 (0)