Skip to content

Commit a810aef

Browse files
authored
Merge branch 'main' into oneof-v2
2 parents d88d62a + f8f2fac commit a810aef

8 files changed

+156
-76
lines changed

.github/algorithm-format-check.mjs

+68-5
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@ for (const filename of filenames) {
2323
{
2424
// Is it an algorithm definition?
2525
const matches = line.match(/^([a-z0-9A-Z]+)(\s*)\(([^)]*)\)(\s*):(\s*)$/);
26+
const grammarMatches =
27+
filename === "Section 2 -- Language.md" &&
28+
line.match(/^([A-Za-z0-9]+) :\s+((\S).*)$/);
2629
if (matches) {
2730
const [, algorithmName, ns1, _args, ns2, ns3] = matches;
2831
if (ns1 || ns2 || ns3) {
2932
console.log(
3033
`Bad whitespace in definition of ${algorithmName} in '${filename}':`
3134
);
32-
console.log(line);
35+
console.dir(line);
3336
console.log();
3437
process.exitCode = 1;
3538
}
@@ -47,7 +50,7 @@ for (const filename of filenames) {
4750
console.log(
4851
`Bad algorithm ${algorithmName} step in '${filename}':`
4952
);
50-
console.log(step);
53+
console.dir(step);
5154
console.log();
5255
process.exitCode = 1;
5356
}
@@ -57,15 +60,15 @@ for (const filename of filenames) {
5760
console.log(
5861
`Bad formatting for '${algorithmName}' step (does not end in '.' or ':') in '${filename}':`
5962
);
60-
console.log(step);
63+
console.dir(step);
6164
console.log();
6265
process.exitCode = 1;
6366
}
6467
if (step.match(/^\s*(-|[0-9]\.)\s+[a-z]/)) {
6568
console.log(
6669
`Bad formatting of '${algorithmName}' step (should start with a capital) in '${filename}':`
6770
);
68-
console.log(step);
71+
console.dir(step);
6972
console.log();
7073
process.exitCode = 1;
7174
}
@@ -79,7 +82,67 @@ for (const filename of filenames) {
7982
console.log(
8083
`Potential bad formatting of '${algorithmName}' step (true/false/null should be wrapped in curly braces, e.g. '{true}') in '${filename}':`
8184
);
82-
console.log(step);
85+
console.dir(step);
86+
console.log();
87+
process.exitCode = 1;
88+
}
89+
}
90+
} else if (grammarMatches) {
91+
// This is super loosey-goosey
92+
const [, grammarName, rest] = grammarMatches;
93+
if (rest.trim() === "one of") {
94+
// Still grammar, not algorithm
95+
continue;
96+
}
97+
if (rest.trim() === "" && lines[i + 1] !== "") {
98+
console.log(
99+
`No empty space after grammar ${grammarName} header in '${filename}'`
100+
);
101+
console.log();
102+
process.exitCode = 1;
103+
}
104+
if (!lines[i + 2].startsWith("- ")) {
105+
// Not an algorithm; probably more grammar
106+
continue;
107+
}
108+
for (let j = i + 2; j < l; j++) {
109+
const step = lines[j];
110+
if (!step.match(/^\s*(-|[0-9]+\.) /)) {
111+
if (step !== "") {
112+
console.log(`Bad grammar ${grammarName} step in '${filename}':`);
113+
console.dir(step);
114+
console.log();
115+
process.exitCode = 1;
116+
}
117+
break;
118+
}
119+
if (!step.match(/[.:]$/)) {
120+
console.log(
121+
`Bad formatting for '${grammarName}' step (does not end in '.' or ':') in '${filename}':`
122+
);
123+
console.dir(step);
124+
console.log();
125+
process.exitCode = 1;
126+
}
127+
if (step.match(/^\s*(-|[0-9]\.)\s+[a-z]/)) {
128+
console.log(
129+
`Bad formatting of '${grammarName}' step (should start with a capital) in '${filename}':`
130+
);
131+
console.dir(step);
132+
console.log();
133+
process.exitCode = 1;
134+
}
135+
const trimmedInnerLine = step.replace(/\s+/g, " ");
136+
if (
137+
trimmedInnerLine.match(
138+
/(?:[rR]eturn|is (?:not )?)(true|false|null)\b/
139+
) &&
140+
!trimmedInnerLine.match(/null or empty/)
141+
) {
142+
console.log(
143+
`Potential bad formatting of '${grammarName}' step (true/false/null should be wrapped in curly braces, e.g. '{true}') in '${filename}':`
144+
);
145+
console.dir(step);
83146
console.log();
84147
process.exitCode = 1;
85148
}

cspell.yml

+4
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,7 @@ words:
2323
- zuckerberg
2424
- brontie
2525
- oneOf
26+
# Forbid Alternative spellings
27+
flagWords:
28+
- implementor
29+
- implementors

spec/Section 2 -- Language.md

+12-8
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,8 @@ There are three types of operations that GraphQL models:
291291
- subscription - a long-lived request that fetches data in response to source
292292
events.
293293

294-
Each operation is represented by an optional operation name and a selection set.
294+
Each operation is represented by an optional operation name and a _selection
295+
set_.
295296

296297
For example, this mutation operation might "like" a story and then retrieve the
297298
new number of likes:
@@ -337,6 +338,9 @@ An operation selects the set of information it needs, and will receive exactly
337338
that information and nothing more, avoiding over-fetching and under-fetching
338339
data.
339340

341+
:: A _selection set_ defines an ordered set of selections (fields, fragment
342+
spreads and inline fragments) against an object, union or interface type.
343+
340344
```graphql example
341345
{
342346
id
@@ -346,14 +350,14 @@ data.
346350
```
347351

348352
In this query operation, the `id`, `firstName`, and `lastName` fields form a
349-
selection set. Selection sets may also contain fragment references.
353+
_selection set_. Selection sets may also contain fragment references.
350354

351355
## Fields
352356

353357
Field : Alias? Name Arguments? Directives? SelectionSet?
354358

355-
A selection set is primarily composed of fields. A field describes one discrete
356-
piece of information available to request within a selection set.
359+
A _selection set_ is primarily composed of fields. A field describes one
360+
discrete piece of information available to request within a selection set.
357361

358362
Some fields describe complex data or relationships to other data. In order to
359363
further explore this data, a field may itself contain a selection set, allowing
@@ -381,7 +385,7 @@ down to scalar values.
381385
}
382386
```
383387

384-
Fields in the top-level selection set of an operation often represent some
388+
Fields in the top-level _selection set_ of an operation often represent some
385389
information that is globally accessible to your application and its current
386390
viewer. Some typical examples of these top fields include references to a
387391
current logged-in viewer, or accessing certain types of data referenced by a
@@ -667,9 +671,9 @@ be present and `likers` will not. Conversely when the result is a `Page`,
667671

668672
InlineFragment : ... TypeCondition? Directives? SelectionSet
669673

670-
Fragments can also be defined inline within a selection set. This is useful for
671-
conditionally including fields based on a type condition or applying a directive
672-
to a selection set.
674+
Fragments can also be defined inline within a _selection set_. This is useful
675+
for conditionally including fields based on a type condition or applying a
676+
directive to a selection set.
673677

674678
This feature of standard fragment inclusion was demonstrated in the
675679
`query FragmentTyping` example above. We could accomplish the same thing using

spec/Section 3 -- Type System.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,8 @@ operations, Objects describe the intermediate levels.
677677
GraphQL Objects represent a list of named fields, each of which yield a value of
678678
a specific type. Object values should be serialized as ordered maps, where the
679679
selected field names (or aliases) are the keys and the result of evaluating the
680-
field is the value, ordered by the order in which they appear in the selection
681-
set.
680+
field is the value, ordered by the order in which they appear in the _selection
681+
set_.
682682

683683
All fields defined within an Object type must not have a name which begins with
684684
{"\_\_"} (two underscores), as this is used exclusively by GraphQL's
@@ -1026,7 +1026,7 @@ Object, Interface, or Union type).
10261026
### Field Deprecation
10271027

10281028
Fields in an object may be marked as deprecated as deemed necessary by the
1029-
application. It is still legal to include these fields in a selection set (to
1029+
application. It is still legal to include these fields in a _selection set_ (to
10301030
ensure existing clients are not broken by the change), but the fields should be
10311031
appropriately treated in documentation and tooling.
10321032

@@ -1142,7 +1142,7 @@ type Contact {
11421142
}
11431143
```
11441144

1145-
This allows us to write a selection set for a `Contact` that can select the
1145+
This allows us to write a _selection set_ for a `Contact` that can select the
11461146
common fields.
11471147

11481148
```graphql example
@@ -1881,9 +1881,9 @@ to denote a field that uses a Non-Null type like this: `name: String!`.
18811881

18821882
**Nullable vs. Optional**
18831883

1884-
Fields are _always_ optional within the context of a selection set, a field may
1885-
be omitted and the selection set is still valid (so long as the selection set
1886-
does not become empty). However fields that return Non-Null types will never
1884+
Fields are _always_ optional within the context of a _selection set_, a field
1885+
may be omitted and the selection set is still valid (so long as the selection
1886+
set does not become empty). However fields that return Non-Null types will never
18871887
return the value {null} if queried.
18881888

18891889
Inputs (such as field arguments), are always optional by default. However a

spec/Section 4 -- Introspection.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ underscores {"\_\_"}.
6868

6969
## Type Name Introspection
7070

71-
GraphQL supports type name introspection within any selection set in an
71+
GraphQL supports type name introspection within any _selection set_ in an
7272
operation, with the single exception of selections at the root of a subscription
7373
operation. Type name introspection is accomplished via the meta-field
7474
`__typename: String!` on any Object, Interface, or Union. It returns the name of

spec/Section 5 -- Validation.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ fragment aliasedLyingFieldTargetNotDefined on Dog {
383383
```
384384

385385
For interfaces, direct field selection can only be done on fields. Fields of
386-
concrete implementors are not relevant to the validity of the given
386+
concrete implementers are not relevant to the validity of the given
387387
interface-typed selection set.
388388

389389
For example, the following is valid:
@@ -397,7 +397,7 @@ fragment interfaceFieldSelection on Pet {
397397
and the following is invalid:
398398

399399
```graphql counter-example
400-
fragment definedOnImplementorsButNotInterface on Pet {
400+
fragment definedOnImplementersButNotInterface on Pet {
401401
nickname
402402
}
403403
```
@@ -467,7 +467,8 @@ SameResponseShape(fieldA, fieldB):
467467
- If {typeA} or {typeB} is Scalar or Enum:
468468
- If {typeA} and {typeB} are the same type return {true}, otherwise return
469469
{false}.
470-
- Assert: {typeA} and {typeB} are both composite types.
470+
- Assert: {typeA} is an object, union or interface type.
471+
- Assert: {typeB} is an object, union or interface type.
471472
- Let {mergedSet} be the result of adding the selection set of {fieldA} and the
472473
selection set of {fieldB}.
473474
- Let {fieldsForName} be the set of selections with a given response name in
@@ -476,6 +477,9 @@ SameResponseShape(fieldA, fieldB):
476477
- If {SameResponseShape(subfieldA, subfieldB)} is {false}, return {false}.
477478
- Return {true}.
478479

480+
Note: In prior versions of the spec the term "composite" was used to signal a
481+
type that is either an Object, Interface or Union type.
482+
479483
**Explanatory Text**
480484

481485
If multiple field selections with the same response names are encountered during
@@ -931,7 +935,7 @@ fragment inlineNotExistingType on Dog {
931935
}
932936
```
933937

934-
#### Fragments on Composite Types
938+
#### Fragments on Object, Interface or Union Types
935939

936940
**Formal Specification**
937941

0 commit comments

Comments
 (0)