Skip to content

Commit 2236275

Browse files
committed
Refactor descriptions text, incorporating feedback from working group
1 parent 6d7b259 commit 2236275

File tree

2 files changed

+64
-62
lines changed

2 files changed

+64
-62
lines changed

spec/Section 2 -- Language.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,67 @@ defined using the Markdown syntax (as specified by
286286

287287
Descriptions may appear before:
288288

289+
**In type system definitions:**
290+
- Schema definitions.
291+
- Type definitions (scalars, objects, interfaces, unions, enums, input objects).
292+
- Field definitions.
293+
- Argument definitions.
294+
- Enum value definitions.
295+
- Input field definitions.
296+
- Directive definitions.
297+
298+
**In executable documents:**
289299
- Operation definitions (queries, mutations, subscriptions) in their full form
290300
(not the shorthand form).
291301
- Fragment definitions.
292302
- Variable definitions within operation definitions.
293303

304+
As an example, this simple GraphQL schema is well described:
305+
306+
```raw graphql example
307+
"""
308+
A simple GraphQL schema which is well described.
309+
"""
310+
schema {
311+
query: Query
312+
}
313+
314+
"""
315+
Root type for all your query operations
316+
"""
317+
type Query {
318+
"""
319+
Translates a string from a given language into a different language.
320+
"""
321+
translate(
322+
"The original language that `text` is provided in."
323+
fromLanguage: Language
324+
325+
"The translated language to be returned."
326+
toLanguage: Language
327+
328+
"The text to be translated."
329+
text: String
330+
): String
331+
}
332+
333+
"""
334+
The set of languages supported by `translate`.
335+
"""
336+
enum Language {
337+
"English"
338+
EN
339+
340+
"French"
341+
FR
342+
343+
"Chinese"
344+
CH
345+
}
346+
```
347+
348+
This is an example of a well-described executable document:
349+
294350
```graphql example
295351
"""
296352
Request the current status of a time machine and its operator.
@@ -341,6 +397,10 @@ documentation purposes. They MUST NOT affect the execution, validation, or
341397
response of a GraphQL document. It is safe to remove all descriptions and
342398
comments from executable documents without changing their behavior or results.
343399

400+
Descriptions in type system definitions are made available via introspection,
401+
ensuring the documentation of a GraphQL service remains consistent with its
402+
capabilities.
403+
344404
## Operations
345405

346406
OperationDefinition :

spec/Section 3 -- Type System.md

Lines changed: 4 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -50,71 +50,13 @@ Tools which only seek to produce and extend schema and not execute requests may
5050
choose to only allow {TypeSystemExtensionDocument} and not allow
5151
{ExecutableDefinition} but should provide a descriptive error if present.
5252

53-
## Descriptions
53+
## Type System Descriptions
5454

55-
Description : StringValue
55+
Documentation is a first-class feature of GraphQL type systems. GraphQL schema and all other definitions (e.g. types, fields, arguments, etc.) which can be described should provide a {Description} unless they are considered self descriptive.
5656

57-
Documentation is a first-class feature of GraphQL type systems. To ensure the
58-
documentation of a GraphQL service remains consistent with its capabilities,
59-
descriptions of GraphQL definitions are provided alongside their definitions and
60-
made available via introspection.
57+
Descriptions in the type system definition language occur immediately before the definition they describe and are made available via introspection, ensuring the documentation of a GraphQL service remains consistent with its capabilities.
6158

62-
Note: See Section 2, "Descriptions", for normative rules and additional details
63-
on descriptions in executable documents.
64-
65-
To allow GraphQL service designers to easily publish documentation alongside the
66-
capabilities of a GraphQL service, GraphQL descriptions are defined using the
67-
Markdown syntax (as specified by [CommonMark](https://commonmark.org/)). In the
68-
type system definition language, these description strings (often {BlockString})
69-
occur immediately before the definition they describe.
70-
71-
GraphQL schema and all other definitions (e.g. types, fields, arguments, etc.)
72-
which can be described should provide a {Description} unless they are considered
73-
self descriptive.
74-
75-
As an example, this simple GraphQL schema is well described:
76-
77-
```raw graphql example
78-
"""
79-
A simple GraphQL schema which is well described.
80-
"""
81-
schema {
82-
query: Query
83-
}
84-
85-
"""
86-
Root type for all your query operations
87-
"""
88-
type Query {
89-
"""
90-
Translates a string from a given language into a different language.
91-
"""
92-
translate(
93-
"The original language that `text` is provided in."
94-
fromLanguage: Language
95-
96-
"The translated language to be returned."
97-
toLanguage: Language
98-
99-
"The text to be translated."
100-
text: String
101-
): String
102-
}
103-
104-
"""
105-
The set of languages supported by `translate`.
106-
"""
107-
enum Language {
108-
"English"
109-
EN
110-
111-
"French"
112-
FR
113-
114-
"Chinese"
115-
CH
116-
}
117-
```
59+
Note: See Section 2, "Descriptions", for normative rules and syntax details. Type system descriptions follow the same Markdown format and rules as executable document descriptions.
11860

11961
## Schema
12062

0 commit comments

Comments
 (0)