Skip to content

Commit 2c8aec8

Browse files
benjiemagicmark
authored andcommitted
Use :: syntax for enum values
1 parent 8ad67a6 commit 2c8aec8

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

@@ -426,17 +429,20 @@ TypeSystemDirectiveLocation : one of
426429
SchemaCoordinate :
427430

428431
- TypeCoordinate
429-
- MemberCoordinate
432+
- FieldCoordinate
430433
- ArgumentCoordinate
434+
- ValueCoordinate
431435
- DirectiveCoordinate
432436
- DirectiveArgumentCoordinate
433437

434438
TypeCoordinate : Name
435439

436-
MemberCoordinate : Name . Name
440+
FieldCoordinate : Name . Name
437441

438442
ArgumentCoordinate : Name . Name ( Name : )
439443

444+
ValueCoordinate : Name :: Name
445+
440446
DirectiveCoordinate : @ Name
441447

442448
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
@@ -2233,17 +2233,20 @@ scalar UUID @specifiedBy(url: "https://tools.ietf.org/html/rfc4122")
22332233
SchemaCoordinate :
22342234

22352235
- TypeCoordinate
2236-
- MemberCoordinate
2236+
- FieldCoordinate
22372237
- ArgumentCoordinate
2238+
- ValueCoordinate
22382239
- DirectiveCoordinate
22392240
- DirectiveArgumentCoordinate
22402241

22412242
TypeCoordinate : Name
22422243

2243-
MemberCoordinate : Name . Name
2244+
FieldCoordinate : Name . Name
22442245

22452246
ArgumentCoordinate : Name . Name ( Name : )
22462247

2248+
ValueCoordinate : Name :: Name
2249+
22472250
DirectiveCoordinate : @ Name
22482251

22492252
DirectiveArgumentCoordinate : @ Name ( Name : )
@@ -2254,6 +2257,16 @@ _schema element_ within a GraphQL Schema.
22542257
:: A _schema element_ can be a named type, a field, an input field, an enum
22552258
value, a field argument, a directive, or a directive argument.
22562259

2260+
:: The _containing element_ of a _schema element_ is the schema element with one
2261+
fewer {Name} token that syntactically contains it. For example:
2262+
2263+
- The containing element of an {ArgumentCoordinate} or
2264+
{DirectiveArgumentCoordinate} is the corresponding {FieldCoordinate} or
2265+
{DirectiveCoordinate} respectively.
2266+
- The containing element of a {FieldCoordinate} or {ValueCoordinate} is its
2267+
containing {TypeCoordinate}.
2268+
- {TypeCoordinate} and {DirectiveCoordinate} have no containing element.
2269+
22572270
A _schema coordinate_ is always unique. Each _schema element_ can be referenced
22582271
by exactly one possible schema coordinate.
22592272

@@ -2279,31 +2292,27 @@ production.
22792292
To refer to a _schema element_, a _schema coordinate_ must be interpreted in the
22802293
context of a GraphQL {schema}.
22812294

2282-
If the _schema element_ cannot be found, the resolve function will not yield a
2283-
value (without raising an error). However, an error will be raised if any
2284-
non-leaf nodes within a _schema coordinate_ cannot be found in the {schema}.
2295+
If the _schema element_ cannot be found, and either it has no _containing
2296+
element_ or its _containing element_ exists and is of the expected type, the
2297+
resolve function returns {null}. Otherwise, an error is raised.
22852298

22862299
TypeCoordinate : Name
22872300

22882301
1. Let {typeName} be the value of {Name}.
22892302
2. Return the type in the {schema} named {typeName}, or {null} if no such type
22902303
exists.
22912304

2292-
MemberCoordinate : Name . Name
2305+
FieldCoordinate : Name . Name
22932306

22942307
1. Let {typeName} be the value of the first {Name}.
22952308
2. Let {type} be the type in the {schema} named {typeName}.
2296-
3. Assert: {type} must exist, and must be an Enum, Input Object, Object or
2297-
Interface type.
2298-
4. If {type} is an Enum type:
2299-
1. Let {enumValueName} be the value of the second {Name}.
2300-
2. Return the enum value of {type} named {enumValueName}, or {null} if no
2301-
such value exists.
2302-
5. Otherwise, if {type} is an Input Object type:
2309+
3. Assert: {type} must exist, and must be an Input Object, Object or Interface
2310+
type.
2311+
4. If {type} is an Input Object type:
23032312
1. Let {inputFieldName} be the value of the second {Name}.
23042313
2. Return the input field of {type} named {inputFieldName}, or {null} if no
23052314
such input field exists.
2306-
6. Otherwise:
2315+
5. Otherwise:
23072316
1. Let {fieldName} be the value of the second {Name}.
23082317
2. Return the field of {type} named {fieldName}, or {null} if no such field
23092318
exists.
@@ -2320,6 +2329,15 @@ ArgumentCoordinate : Name . Name ( Name : )
23202329
8. Return the argument of {field} named {fieldArgumentName}, or {null} if no
23212330
such argument exists.
23222331

2332+
ValueCoordinate : Name :: Name
2333+
2334+
1. Let {typeName} be the value of the first {Name}.
2335+
2. Let {type} be the type in the {schema} named {typeName}.
2336+
3. Assert: {type} must exist, and must be an Enum type.
2337+
4. Let {enumValueName} be the value of the second {Name}.
2338+
5. Return the enum value of {type} named {enumValueName}, or {null} if no such
2339+
value exists.
2340+
23232341
DirectiveCoordinate : @ Name
23242342

23252343
1. Let {directiveName} be the value of {Name}.
@@ -2342,8 +2360,8 @@ DirectiveArgumentCoordinate : @ Name ( Name : )
23422360
| Named Type | `Business` | `Business` type |
23432361
| Field | `Business.name` | `name` field on the `Business` type |
23442362
| Input Field | `SearchCriteria.filter` | `filter` input field on the `SearchCriteria` input object type |
2345-
| Enum Value | `SearchFilter.OPEN_NOW` | `OPEN_NOW` value of the `SearchFilter` enum |
23462363
| Field Argument | `Query.searchBusiness(criteria:)` | `criteria` argument on the `searchBusiness` field on the `Query` type |
2364+
| Enum Value | `SearchFilter::OPEN_NOW` | `OPEN_NOW` value of the `SearchFilter` enum |
23472365
| Directive | `@private` | `@private` directive |
23482366
| Directive Argument | `@private(scope:)` | `scope` argument on the `@private` directive |
23492367

0 commit comments

Comments
 (0)