Skip to content

Commit f8fd141

Browse files
authored
Merge branch 'main' into Shane32-patch-1
2 parents 6f187fa + e546aac commit f8fd141

File tree

6 files changed

+104
-28
lines changed

6 files changed

+104
-28
lines changed

.github/algorithm-format-check.mjs

Lines changed: 68 additions & 5 deletions
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
}

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[![GraphQLConf 2024 Banner: September 10-12, San Francisco. Hosted by the GraphQL Foundation](https://github.com/user-attachments/assets/0203f10b-ae1e-4fe1-9222-6547fa2bbd5d)](https://graphql.org/conf/2024/?utm_source=github&utm_medium=graphql_spec&utm_campaign=readme)
2+
13
# GraphQL
24

35
<img alt="GraphQL Logo" align="right" src="https://graphql.org/img/logo.svg" width="15%" />

cspell.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ words:
2121
- tatooine
2222
- zuck
2323
- zuckerberg
24+
# Forbid Alternative spellings
25+
flagWords:
26+
- implementor
27+
- implementors

spec/Section 5 -- Validation.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ fragment aliasedLyingFieldTargetNotDefined on Dog {
394394
```
395395

396396
For interfaces, direct field selection can only be done on fields. Fields of
397-
concrete implementors are not relevant to the validity of the given
397+
concrete implementers are not relevant to the validity of the given
398398
interface-typed selection set.
399399

400400
For example, the following is valid:
@@ -408,7 +408,7 @@ fragment interfaceFieldSelection on Pet {
408408
and the following is invalid:
409409

410410
```graphql counter-example
411-
fragment definedOnImplementorsButNotInterface on Pet {
411+
fragment definedOnImplementersButNotInterface on Pet {
412412
nickname
413413
}
414414
```
@@ -478,7 +478,8 @@ SameResponseShape(fieldA, fieldB):
478478
- If {typeA} or {typeB} is Scalar or Enum:
479479
- If {typeA} and {typeB} are the same type return {true}, otherwise return
480480
{false}.
481-
- Assert: {typeA} and {typeB} are both composite types.
481+
- Assert: {typeA} is an object, union or interface type.
482+
- Assert: {typeB} is an object, union or interface type.
482483
- Let {mergedSet} be the result of adding the selection set of {fieldA} and the
483484
selection set of {fieldB}.
484485
- Let {fieldsForName} be the set of selections with a given response name in
@@ -487,6 +488,9 @@ SameResponseShape(fieldA, fieldB):
487488
- If {SameResponseShape(subfieldA, subfieldB)} is {false}, return {false}.
488489
- Return {true}.
489490

491+
Note: In prior versions of the spec the term "composite" was used to signal a
492+
type that is either an Object, Interface or Union type.
493+
490494
**Explanatory Text**
491495

492496
If multiple field selections with the same response names are encountered during
@@ -942,7 +946,7 @@ fragment inlineNotExistingType on Dog {
942946
}
943947
```
944948

945-
#### Fragments on Composite Types
949+
#### Fragments on Object, Interface or Union Types
946950

947951
**Formal Specification**
948952

spec/Section 6 -- Execution.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,21 @@ A GraphQL service generates a response from a request via execution.
44

55
:: A _request_ for execution consists of a few pieces of information:
66

7-
- The schema to use, typically solely provided by the GraphQL service.
8-
- A {Document} which must contain GraphQL {OperationDefinition} and may contain
9-
{FragmentDefinition}.
10-
- Optionally: The name of the Operation in the Document to execute.
11-
- Optionally: Values for any Variables defined by the Operation.
12-
- An initial value corresponding to the root type being executed. Conceptually,
13-
an initial value represents the "universe" of data available via a GraphQL
14-
Service. It is common for a GraphQL Service to always use the same initial
15-
value for every request.
16-
17-
Given this information, the result of {ExecuteRequest()} produces the response,
18-
to be formatted according to the Response section below.
7+
- {schema}: The schema to use, typically solely provided by the GraphQL service.
8+
- {document}: A {Document} which must contain GraphQL {OperationDefinition} and
9+
may contain {FragmentDefinition}.
10+
- {operationName} (optional): The name of the Operation in the Document to
11+
execute.
12+
- {variableValues} (optional): Values for any Variables defined by the
13+
Operation.
14+
- {initialValue} (optional): An initial value corresponding to the root type
15+
being executed. Conceptually, an initial value represents the "universe" of
16+
data available via a GraphQL Service. It is common for a GraphQL Service to
17+
always use the same initial value for every request.
18+
19+
Given this information, the result of {ExecuteRequest(schema, document,
20+
operationName, variableValues, initialValue)} produces the response, to be
21+
formatted according to the Response section below.
1922

2023
Note: GraphQL requests do not require any specific serialization format or
2124
transport mechanism. Message serialization and transport mechanisms should be
@@ -290,11 +293,11 @@ subscription _selection set_ using that event as a root value.
290293
MapSourceToResponseEvent(sourceStream, subscription, schema, variableValues):
291294

292295
- Return a new event stream {responseStream} which yields events as follows:
293-
- For each {event} on {sourceStream}:
294-
- Let {response} be the result of running
295-
{ExecuteSubscriptionEvent(subscription, schema, variableValues, event)}.
296-
- Yield an event containing {response}.
297-
- When {responseStream} completes: complete this event stream.
296+
- For each {event} on {sourceStream}:
297+
- Let {response} be the result of running
298+
{ExecuteSubscriptionEvent(subscription, schema, variableValues, event)}.
299+
- Yield an event containing {response}.
300+
- When {sourceStream} completes: complete {responseStream}.
298301

299302
ExecuteSubscriptionEvent(subscription, schema, variableValues, initialValue):
300303

spec/Section 7 -- Response.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ request failed before execution, due to a syntax error, missing information, or
2323
validation error, this entry must not be present.
2424

2525
The response map may also contain an entry with key `extensions`. This entry, if
26-
set, must have a map as its value. This entry is reserved for implementors to
26+
set, must have a map as its value. This entry is reserved for implementers to
2727
extend the protocol however they see fit, and hence there are no additional
2828
restrictions on its contents.
2929

@@ -203,7 +203,7 @@ be the same:
203203

204204
GraphQL services may provide an additional entry to errors with key
205205
`extensions`. This entry, if set, must have a map as its value. This entry is
206-
reserved for implementors to add additional information to errors however they
206+
reserved for implementers to add additional information to errors however they
207207
see fit, and there are no additional restrictions on its contents.
208208

209209
```json example

0 commit comments

Comments
 (0)