Skip to content

Commit 02fd71f

Browse files
Add description to Schema (#466)
* Move description section * Add description to Schema
1 parent 3b001da commit 02fd71f

File tree

3 files changed

+67
-59
lines changed

3 files changed

+67
-59
lines changed

spec/Appendix B -- Grammar Summary.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ TypeSystemExtension :
218218
- SchemaExtension
219219
- TypeExtension
220220

221-
SchemaDefinition : schema Directives[Const]? { RootOperationTypeDefinition+ }
221+
SchemaDefinition : Description? schema Directives[Const]? { RootOperationTypeDefinition+ }
222222

223223
SchemaExtension :
224224
- extend schema Directives[Const]? { RootOperationTypeDefinition+ }

spec/Section 3 -- Type System.md

Lines changed: 65 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,73 @@ local service to represent data a GraphQL client only accesses locally, or by a
3838
GraphQL service which is itself an extension of another GraphQL service.
3939

4040

41+
## Descriptions
42+
43+
Description : StringValue
44+
45+
Documentation is a first-class feature of GraphQL type systems. To ensure
46+
the documentation of a GraphQL service remains consistent with its capabilities,
47+
descriptions of GraphQL definitions are provided alongside their definitions and
48+
made available via introspection.
49+
50+
To allow GraphQL service designers to easily publish documentation alongside the
51+
capabilities of a GraphQL service, GraphQL descriptions are defined using the
52+
Markdown syntax (as specified by [CommonMark](https://commonmark.org/)). In the
53+
type system definition language, these description strings (often {BlockString})
54+
occur immediately before the definition they describe.
55+
56+
GraphQL schema and all other definitions (e.g. types, fields, arguments, etc.)
57+
which can be described should provide a {Description} unless they are considered
58+
self descriptive.
59+
60+
As an example, this simple GraphQL schema is well described:
61+
62+
```graphql example
63+
"""
64+
A simple GraphQL schema which is well described.
65+
"""
66+
schema {
67+
query: Query
68+
}
69+
70+
"""
71+
Root type for all your queries
72+
"""
73+
type Query {
74+
"""
75+
Translates a string from a given language into a different language.
76+
"""
77+
translate(
78+
"The original language that `text` is provided in."
79+
fromLanguage: Language
80+
81+
"The translated language to be returned."
82+
toLanguage: Language
83+
84+
"The text to be translated."
85+
text: String
86+
): String
87+
}
88+
89+
"""
90+
The set of languages supported by `translate`.
91+
"""
92+
enum Language {
93+
"English"
94+
EN
95+
96+
"French"
97+
FR
98+
99+
"Chinese"
100+
CH
101+
}
102+
```
103+
104+
41105
## Schema
42106

43-
SchemaDefinition : schema Directives[Const]? { RootOperationTypeDefinition+ }
107+
SchemaDefinition : Description? schema Directives[Const]? { RootOperationTypeDefinition+ }
44108

45109
RootOperationTypeDefinition : OperationType : NamedType
46110

@@ -169,63 +233,6 @@ Schema extensions have the potential to be invalid if incorrectly defined.
169233
original Schema.
170234

171235

172-
## Descriptions
173-
174-
Description : StringValue
175-
176-
Documentation is a first-class feature of GraphQL type systems. To ensure
177-
the documentation of a GraphQL service remains consistent with its capabilities,
178-
descriptions of GraphQL definitions are provided alongside their definitions and
179-
made available via introspection.
180-
181-
To allow GraphQL service designers to easily publish documentation alongside the
182-
capabilities of a GraphQL service, GraphQL descriptions are defined using the
183-
Markdown syntax (as specified by [CommonMark](https://commonmark.org/)). In the
184-
type system definition language, these description strings (often {BlockString})
185-
occur immediately before the definition they describe.
186-
187-
All GraphQL types, fields, arguments and other definitions which can be
188-
described should provide a {Description} unless they are considered self
189-
descriptive.
190-
191-
As an example, this simple GraphQL schema is well described:
192-
193-
```graphql example
194-
"""
195-
A simple GraphQL schema which is well described.
196-
"""
197-
type Query {
198-
"""
199-
Translates a string from a given language into a different language.
200-
"""
201-
translate(
202-
"The original language that `text` is provided in."
203-
fromLanguage: Language
204-
205-
"The translated language to be returned."
206-
toLanguage: Language
207-
208-
"The text to be translated."
209-
text: String
210-
): String
211-
}
212-
213-
"""
214-
The set of languages supported by `translate`.
215-
"""
216-
enum Language {
217-
"English"
218-
EN
219-
220-
"French"
221-
FR
222-
223-
"Chinese"
224-
CH
225-
}
226-
```
227-
228-
229236
## Types
230237

231238
TypeDefinition :

spec/Section 4 -- Introspection.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ The schema of the GraphQL schema introspection system:
117117

118118
```graphql
119119
type __Schema {
120+
description: String
120121
types: [__Type!]!
121122
queryType: __Type!
122123
mutationType: __Type

0 commit comments

Comments
 (0)