Skip to content

Commit 9d0710e

Browse files
martinbonninbenjieleebyron
authored
Add Appendix C - Specified Type System Definitions (#1037)
* Add appendix C - builtin definitions * also run prettier * update graphql-js * Update scripts/update-appendix-c.mjs Co-authored-by: Benjie <[email protected]> * add specified scalars * manual tweaking * built-in => specified * another instance of BuiltIn => Specified * update the order of fields to match graphql-js * Update update-appendix-c.mjs line break --------- Co-authored-by: Benjie <[email protected]> Co-authored-by: Lee Byron <[email protected]>
1 parent a44d4ec commit 9d0710e

File tree

6 files changed

+375
-5
lines changed

6 files changed

+375
-5
lines changed

package-lock.json

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@
2121
"suggest:format": "echo \"\nTo resolve this, run: $(tput bold)npm run format$(tput sgr0)\" && exit 1",
2222
"build": "./build.sh",
2323
"test:build": "spec-md --metadata spec/metadata.json spec/GraphQL.md > /dev/null",
24-
"watch": "nodemon -e json,md --exec \"npm run build\""
24+
"watch": "nodemon -e json,md --exec \"npm run build\"",
25+
"update-appendix-c": "node scripts/update-appendix-c.mjs; prettier --write \"spec/Appendix C -- Built-in Definitions.md\""
2526
},
2627
"devDependencies": {
2728
"cspell": "5.9.1",
2829
"nodemon": "2.0.20",
2930
"prettier": "2.8.2",
30-
"spec-md": "3.1.0"
31+
"spec-md": "3.1.0",
32+
"graphql": "^17.0.0-alpha.8"
3133
},
3234
"prettier": {
3335
"proseWrap": "always",

scripts/update-appendix-c.mjs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { writeFile } from 'node:fs/promises';
2+
import { printIntrospectionSchema, buildSchema, specifiedScalarTypes, printType } from 'graphql';
3+
4+
const FILE = './spec/Appendix C -- Specified Definitions.md';
5+
function printSpecifiedScalars() {
6+
return specifiedScalarTypes
7+
.map((type) => printType(type))
8+
.join('\n\n');
9+
}
10+
11+
const introspectionSchema = printIntrospectionSchema(buildSchema(`type Query { i: Int }`));
12+
const prefix = `
13+
# C. Appendix: Type System Definitions
14+
15+
This appendix lists the specified type system definitions.
16+
17+
The descriptions are non-normative. Implementations are recommended to use them
18+
for consistency but different descriptions are allowed.
19+
20+
The order of types, fields, arguments, values and directives is non-normative.
21+
22+
\`\`\`graphql
23+
`
24+
25+
const suffix = `
26+
\`\`\`
27+
`
28+
await writeFile(FILE, prefix + printSpecifiedScalars() + '\n\n' + introspectionSchema + suffix);

0 commit comments

Comments
 (0)