Skip to content

Commit e346598

Browse files
committed
Add appendix C - builtin definitions
1 parent 646f937 commit e346598

File tree

6 files changed

+647
-2
lines changed

6 files changed

+647
-2
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"
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": "^16.11.0"
3133
},
3234
"prettier": {
3335
"proseWrap": "always",

scripts/update-appendix-c.mjs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { writeFile } from 'node:fs/promises';
2+
import { printIntrospectionSchema, buildSchema } from 'graphql';
3+
4+
const FILE = './spec/Appendix C -- Built-in Definitions';
5+
6+
const sdl = printIntrospectionSchema(buildSchema(`type Query { i: Int }`));
7+
const prefix = `
8+
# C. Appendix: Type System Definitions
9+
10+
This appendix lists all the type system definitions mentioned throughout this
11+
specification.
12+
13+
The descriptions are non-normative. Implementations are recommended to use them
14+
for consistency but different descriptions are allowed.
15+
16+
\`\`\`graphql
17+
`
18+
19+
const suffix = `
20+
\`\`\`
21+
`
22+
await writeFile(FILE, prefix + sdl + suffix);
Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
2+
# C. Appendix: Type System Definitions
3+
4+
This appendix lists all the type system definitions mentioned throughout this
5+
specification.
6+
7+
The descriptions are non-normative. Implementations are recommended to use them
8+
for consistency but different descriptions are allowed.
9+
10+
```graphql
11+
"""
12+
Directs the executor to include this field or fragment only when the `if` argument is true.
13+
"""
14+
directive @include(
15+
"""Included when true."""
16+
if: Boolean!
17+
) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
18+
19+
"""
20+
Directs the executor to skip this field or fragment when the `if` argument is true.
21+
"""
22+
directive @skip(
23+
"""Skipped when true."""
24+
if: Boolean!
25+
) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
26+
27+
"""Marks an element of a GraphQL schema as no longer supported."""
28+
directive @deprecated(
29+
"""
30+
Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).
31+
"""
32+
reason: String = "No longer supported"
33+
) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | ENUM_VALUE
34+
35+
"""Exposes a URL that specifies the behavior of this scalar."""
36+
directive @specifiedBy(
37+
"""The URL that specifies the behavior of this scalar."""
38+
url: String!
39+
) on SCALAR
40+
41+
"""
42+
Indicates exactly one field must be supplied and this field must not be `null`.
43+
"""
44+
directive @oneOf on INPUT_OBJECT
45+
46+
"""
47+
A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.
48+
"""
49+
type __Schema {
50+
description: String
51+
52+
"""A list of all types supported by this server."""
53+
types: [__Type!]!
54+
55+
"""The type that query operations will be rooted at."""
56+
queryType: __Type!
57+
58+
"""
59+
If this server supports mutation, the type that mutation operations will be rooted at.
60+
"""
61+
mutationType: __Type
62+
63+
"""
64+
If this server support subscription, the type that subscription operations will be rooted at.
65+
"""
66+
subscriptionType: __Type
67+
68+
"""A list of all directives supported by this server."""
69+
directives: [__Directive!]!
70+
}
71+
72+
"""
73+
The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.
74+
75+
Depending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedByURL`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.
76+
"""
77+
type __Type {
78+
kind: __TypeKind!
79+
name: String
80+
description: String
81+
specifiedByURL: String
82+
fields(includeDeprecated: Boolean = false): [__Field!]
83+
interfaces: [__Type!]
84+
possibleTypes: [__Type!]
85+
enumValues(includeDeprecated: Boolean = false): [__EnumValue!]
86+
inputFields(includeDeprecated: Boolean = false): [__InputValue!]
87+
ofType: __Type
88+
isOneOf: Boolean
89+
}
90+
91+
"""An enum describing what kind of type a given `__Type` is."""
92+
enum __TypeKind {
93+
"""Indicates this type is a scalar."""
94+
SCALAR
95+
96+
"""
97+
Indicates this type is an object. `fields` and `interfaces` are valid fields.
98+
"""
99+
OBJECT
100+
101+
"""
102+
Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields.
103+
"""
104+
INTERFACE
105+
106+
"""Indicates this type is a union. `possibleTypes` is a valid field."""
107+
UNION
108+
109+
"""Indicates this type is an enum. `enumValues` is a valid field."""
110+
ENUM
111+
112+
"""
113+
Indicates this type is an input object. `inputFields` is a valid field.
114+
"""
115+
INPUT_OBJECT
116+
117+
"""Indicates this type is a list. `ofType` is a valid field."""
118+
LIST
119+
120+
"""Indicates this type is a non-null. `ofType` is a valid field."""
121+
NON_NULL
122+
}
123+
124+
"""
125+
Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.
126+
"""
127+
type __Field {
128+
name: String!
129+
description: String
130+
args(includeDeprecated: Boolean = false): [__InputValue!]!
131+
type: __Type!
132+
isDeprecated: Boolean!
133+
deprecationReason: String
134+
}
135+
136+
"""
137+
Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.
138+
"""
139+
type __InputValue {
140+
name: String!
141+
description: String
142+
type: __Type!
143+
144+
"""
145+
A GraphQL-formatted string representing the default value for this input value.
146+
"""
147+
defaultValue: String
148+
isDeprecated: Boolean!
149+
deprecationReason: String
150+
}
151+
152+
"""
153+
One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.
154+
"""
155+
type __EnumValue {
156+
name: String!
157+
description: String
158+
isDeprecated: Boolean!
159+
deprecationReason: String
160+
}
161+
162+
"""
163+
A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.
164+
165+
In some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.
166+
"""
167+
type __Directive {
168+
name: String!
169+
description: String
170+
isRepeatable: Boolean!
171+
locations: [__DirectiveLocation!]!
172+
args(includeDeprecated: Boolean = false): [__InputValue!]!
173+
}
174+
175+
"""
176+
A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.
177+
"""
178+
enum __DirectiveLocation {
179+
"""Location adjacent to a query operation."""
180+
QUERY
181+
182+
"""Location adjacent to a mutation operation."""
183+
MUTATION
184+
185+
"""Location adjacent to a subscription operation."""
186+
SUBSCRIPTION
187+
188+
"""Location adjacent to a field."""
189+
FIELD
190+
191+
"""Location adjacent to a fragment definition."""
192+
FRAGMENT_DEFINITION
193+
194+
"""Location adjacent to a fragment spread."""
195+
FRAGMENT_SPREAD
196+
197+
"""Location adjacent to an inline fragment."""
198+
INLINE_FRAGMENT
199+
200+
"""Location adjacent to a variable definition."""
201+
VARIABLE_DEFINITION
202+
203+
"""Location adjacent to a schema definition."""
204+
SCHEMA
205+
206+
"""Location adjacent to a scalar definition."""
207+
SCALAR
208+
209+
"""Location adjacent to an object type definition."""
210+
OBJECT
211+
212+
"""Location adjacent to a field definition."""
213+
FIELD_DEFINITION
214+
215+
"""Location adjacent to an argument definition."""
216+
ARGUMENT_DEFINITION
217+
218+
"""Location adjacent to an interface definition."""
219+
INTERFACE
220+
221+
"""Location adjacent to a union definition."""
222+
UNION
223+
224+
"""Location adjacent to an enum definition."""
225+
ENUM
226+
227+
"""Location adjacent to an enum value definition."""
228+
ENUM_VALUE
229+
230+
"""Location adjacent to an input object type definition."""
231+
INPUT_OBJECT
232+
233+
"""Location adjacent to an input object field definition."""
234+
INPUT_FIELD_DEFINITION
235+
}
236+
```

0 commit comments

Comments
 (0)