Skip to content

Add Appendix C - Specified Type System Definitions #1037

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
"suggest:format": "echo \"\nTo resolve this, run: $(tput bold)npm run format$(tput sgr0)\" && exit 1",
"build": "./build.sh",
"test:build": "spec-md --metadata spec/metadata.json spec/GraphQL.md > /dev/null",
"watch": "nodemon -e json,md --exec \"npm run build\""
"watch": "nodemon -e json,md --exec \"npm run build\"",
"update-appendix-c": "node scripts/update-appendix-c.mjs; prettier --write \"spec/Appendix C -- Built-in Definitions.md\""
},
"devDependencies": {
"cspell": "5.9.1",
"nodemon": "2.0.20",
"prettier": "2.8.2",
"spec-md": "3.1.0"
"spec-md": "3.1.0",
"graphql": "^17.0.0-alpha.8"
},
"prettier": {
"proseWrap": "always",
Expand Down
28 changes: 28 additions & 0 deletions scripts/update-appendix-c.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { writeFile } from 'node:fs/promises';
import { printIntrospectionSchema, buildSchema, specifiedScalarTypes, printType } from 'graphql';

const FILE = './spec/Appendix C -- Specified Definitions.md';
function printSpecifiedScalars() {
return specifiedScalarTypes
.map((type) => printType(type))
.join('\n\n');
}

const introspectionSchema = printIntrospectionSchema(buildSchema(`type Query { i: Int }`));
const prefix = `
# C. Appendix: Type System Definitions

This appendix lists the specified type system definitions.

The descriptions are non-normative. Implementations are recommended to use them
for consistency but different descriptions are allowed.

The order of types, fields, arguments, values and directives is non-normative.

\`\`\`graphql
`

const suffix = `
\`\`\`
`
await writeFile(FILE, prefix + printSpecifiedScalars() + '\n\n' + introspectionSchema + suffix);
Loading