Skip to content

Commit 10e6a5e

Browse files
committed
Merge branch 'main' into subscription-single-root-field
2 parents 0308b27 + e9ac8c8 commit 10e6a5e

40 files changed

+10844
-9945
lines changed

.github/ISSUE_TEMPLATE.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@
22

33
Before creating your issue:
44

5-
* Have a question? Find community resources at https://graphql.org/community/
5+
- Have a question? Find community resources at https://graphql.org/community/
66

7-
* Find an editing mistake? Create a Pull Request with the edited fix! The Github UI allows you to edit files directly, find the source files at: https://github.com/graphql/graphql-spec/tree/master/spec
7+
- Find an editing mistake? Create a Pull Request with the edited fix! The Github
8+
UI allows you to edit files directly, find the source files at:
9+
https://github.com/graphql/graphql-spec/tree/master/spec
810

9-
* Improvements to documentation? Head over to https://github.com/graphql/graphql.github.io
11+
- Improvements to documentation? Head over to
12+
https://github.com/graphql/graphql.github.io
1013

11-
* Feature request? First read https://github.com/graphql/graphql-spec/blob/master/CONTRIBUTING.md and prefer creating a Pull Request!
14+
- Feature request? First read
15+
https://github.com/graphql/graphql-spec/blob/master/CONTRIBUTING.md and prefer
16+
creating a Pull Request!

.github/PULL_REQUEST_TEMPLATE.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
!!! IMPORTANT !!!
22

3-
Please Read https://github.com/graphql/graphql-spec/blob/master/CONTRIBUTING.md before creating a Pull Request.
3+
Please Read https://github.com/graphql/graphql-spec/blob/master/CONTRIBUTING.md
4+
before creating a Pull Request.

.github/algorithm-format-check.mjs

+177
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
import { readFile, readdir } from "node:fs/promises";
2+
3+
const SPEC_DIR = new URL("../spec", import.meta.url).pathname;
4+
5+
process.exitCode = 0;
6+
const filenames = await readdir(SPEC_DIR);
7+
for (const filename of filenames) {
8+
if (!filename.endsWith(".md")) {
9+
continue;
10+
}
11+
const markdown = await readFile(`${SPEC_DIR}/${filename}`, "utf8");
12+
13+
/**
14+
* Not strictly 'lines' since we try and group indented things together as if
15+
* they were one line. Close enough though.
16+
*/
17+
const lines = markdown.split(/\n(?=[\S\n]|\s*(?:-|[0-9]+\.) )/);
18+
19+
for (let i = 0, l = lines.length; i < l; i++) {
20+
const line = lines[i];
21+
22+
// Check algorithm is consistently formatted
23+
{
24+
// Is it an algorithm definition?
25+
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).*)$/);
29+
if (matches) {
30+
const [, algorithmName, ns1, _args, ns2, ns3] = matches;
31+
if (ns1 || ns2 || ns3) {
32+
console.log(
33+
`Bad whitespace in definition of ${algorithmName} in '${filename}':`
34+
);
35+
console.dir(line);
36+
console.log();
37+
process.exitCode = 1;
38+
}
39+
if (lines[i + 1] !== "") {
40+
console.log(
41+
`No empty space after algorithm ${algorithmName} header in '${filename}'`
42+
);
43+
console.log();
44+
process.exitCode = 1;
45+
}
46+
for (let j = i + 2; j < l; j++) {
47+
const step = lines[j];
48+
if (!step.match(/^\s*(-|[0-9]+\.) /)) {
49+
if (step !== "") {
50+
console.log(
51+
`Bad algorithm ${algorithmName} step in '${filename}':`
52+
);
53+
console.dir(step);
54+
console.log();
55+
process.exitCode = 1;
56+
}
57+
break;
58+
}
59+
if (!step.match(/[.:]$/)) {
60+
console.log(
61+
`Bad formatting for '${algorithmName}' step (does not end in '.' or ':') in '${filename}':`
62+
);
63+
console.dir(step);
64+
console.log();
65+
process.exitCode = 1;
66+
}
67+
if (step.match(/^\s*(-|[0-9]\.)\s+[a-z]/)) {
68+
console.log(
69+
`Bad formatting of '${algorithmName}' step (should start with a capital) in '${filename}':`
70+
);
71+
console.dir(step);
72+
console.log();
73+
process.exitCode = 1;
74+
}
75+
const trimmedInnerLine = step.replace(/\s+/g, " ");
76+
if (
77+
trimmedInnerLine.match(
78+
/(?:[rR]eturn|is (?:not )?)(true|false|null)\b/
79+
) &&
80+
!trimmedInnerLine.match(/null or empty/)
81+
) {
82+
console.log(
83+
`Potential bad formatting of '${algorithmName}' step (true/false/null should be wrapped in curly braces, e.g. '{true}') in '${filename}':`
84+
);
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);
146+
console.log();
147+
process.exitCode = 1;
148+
}
149+
}
150+
}
151+
}
152+
153+
// Check `- ...:` step is followed by an indent
154+
{
155+
const matches = line.match(/^(\s*)- .*:\s*$/);
156+
if (matches) {
157+
const indent = matches[1];
158+
const nextLine = lines[i + 1];
159+
if (!nextLine.startsWith(`${indent} `)) {
160+
console.log(
161+
`Lacking indent in '${filename}' following ':' character:`
162+
);
163+
console.dir(line);
164+
console.dir(nextLine);
165+
console.log();
166+
// TODO: process.exitCode = 1;
167+
}
168+
}
169+
}
170+
}
171+
}
172+
173+
if (process.exitCode === 0) {
174+
console.log(`Everything looks okay!`);
175+
} else {
176+
console.log(`Please resolve the errors detailed above.`);
177+
}

.github/workflows/ci.yml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
test-spelling:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- uses: actions/setup-node@v3
15+
- run: npm ci
16+
- run: npm run test:spelling
17+
test-format:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v3
21+
- uses: actions/setup-node@v3
22+
- run: npm ci
23+
- run: npm run test:format
24+
- run: npm run test:algorithm-format
25+
test-build:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v3
29+
- uses: actions/setup-node@v3
30+
- run: npm ci
31+
- run: npm run test:build
32+
publish:
33+
if: github.ref == 'refs/heads/main'
34+
needs:
35+
- test-spelling
36+
- test-format
37+
- test-build
38+
runs-on: ubuntu-latest
39+
steps:
40+
- uses: actions/checkout@v3
41+
with:
42+
fetch-depth: 0
43+
- uses: actions/setup-node@v3
44+
- run: npm ci
45+
- run: npm run build
46+
- uses: peaceiris/actions-gh-pages@v3
47+
with:
48+
github_token: ${{ secrets.GITHUB_TOKEN }}
49+
keep_files: true
50+
cname: spec.graphql.org
51+
user_name: "github-actions[bot]"
52+
user_email: "github-actions[bot]@users.noreply.github.com"

.github/workflows/test.yml

-12
This file was deleted.

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
.DS_Store
55
npm-debug.log
66
/build
7-
/out
7+
/public
88
/gh-pages
99
/node_modules

.prettierignore

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
*.swp
2+
*~
3+
.*.haste_cache.*
4+
.DS_Store
5+
npm-debug.log
6+
/build
7+
/changelogs
8+
/out
9+
/gh-pages
10+
/node_modules
11+
/package.json

.travis.yml

-25
This file was deleted.

0 commit comments

Comments
 (0)