Skip to content

Commit fa541c3

Browse files
committed
add specified scalars
1 parent 36bb5d6 commit fa541c3

File tree

2 files changed

+37
-7
lines changed

2 files changed

+37
-7
lines changed

scripts/update-appendix-c.mjs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import { writeFile } from 'node:fs/promises';
2-
import { printIntrospectionSchema, buildSchema } from 'graphql';
2+
import { printIntrospectionSchema, buildSchema, specifiedScalarTypes, printType } from 'graphql';
33

44
const FILE = './spec/Appendix C -- Built-in Definitions.md';
5+
function printSpecifiedScalars() {
6+
return specifiedScalarTypes
7+
.map((type) => printType(type))
8+
.join('\n\n');
9+
}
510

6-
const sdl = printIntrospectionSchema(buildSchema(`type Query { i: Int }`));
11+
const introspectionSchema = printIntrospectionSchema(buildSchema(`type Query { i: Int }`));
712
const prefix = `
813
# C. Appendix: Type System Definitions
914
10-
This appendix lists all the type system definitions mentioned throughout this
11-
specification.
15+
This appendix lists the specified type system definitions.
1216
1317
The descriptions are non-normative. Implementations are recommended to use them
1418
for consistency but different descriptions are allowed.
@@ -21,4 +25,4 @@ The order of types, fields, arguments, values and directives is non-normative.
2125
const suffix = `
2226
\`\`\`
2327
`
24-
await writeFile(FILE, prefix + sdl + suffix);
28+
await writeFile(FILE, prefix + printSpecifiedScalars() + '\n\n' + introspectionSchema + suffix);

spec/Appendix C -- Built-in Definitions.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,38 @@
11
# C. Appendix: Type System Definitions
22

3-
This appendix lists all the type system definitions mentioned throughout this
4-
specification.
3+
This appendix lists the built-in type system definitions.
54

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

8+
The order of types, fields, arguments, values and directives is non-normative.
9+
910
```graphql
11+
"""
12+
The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.
13+
"""
14+
scalar String
15+
16+
"""
17+
The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.
18+
"""
19+
scalar Int
20+
21+
"""
22+
The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).
23+
"""
24+
scalar Float
25+
26+
"""
27+
The `Boolean` scalar type represents `true` or `false`.
28+
"""
29+
scalar Boolean
30+
31+
"""
32+
The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `"4"`) or integer (such as `4`) input value will be accepted as an ID.
33+
"""
34+
scalar ID
35+
1036
"""
1137
Directs the executor to include this field or fragment only when the `if` argument is true.
1238
"""

0 commit comments

Comments
 (0)