Skip to content

Commit 369dc2b

Browse files
committed
editorial: move examples back to type system, add some links
1 parent 07be572 commit 369dc2b

File tree

2 files changed

+70
-103
lines changed

2 files changed

+70
-103
lines changed

spec/Section 2 -- Language.md

Lines changed: 14 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -238,80 +238,16 @@ defined by this specification.
238238
Description : StringValue
239239

240240
Documentation is a first-class feature of GraphQL by encouraging written
241-
descriptions on all named definitions in both a GraphQL schema
242-
{TypeSystemDocument} and an executable {Document}. GraphQL descriptions are
243-
expected to provided as Markdown (as specified by
244-
[CommonMark](https://commonmark.org/)). Description strings (often
245-
{BlockString}) occur immediately before the named definition they describe.
246-
247-
Descriptions in type system definitions are made available via introspection,
248-
ensuring the documentation of a GraphQL service remains consistent with its
249-
capabilities.
250-
251-
Descriptions may appear before:
252-
253-
**In type system definitions:**
254-
255-
- Schema definitions.
256-
- Type definitions (scalars, objects, interfaces, unions, enums, input objects).
257-
- Field definitions.
258-
- Argument definitions.
259-
- Enum value definitions.
260-
- Input field definitions.
261-
- Directive definitions.
262-
263-
**In executable documents:**
264-
265-
- Operation definitions (queries, mutations, subscriptions) in their full form
266-
(not the shorthand form).
267-
- Fragment definitions.
268-
- Variable definitions within operation definitions.
269-
270-
As an example, this simple GraphQL schema is well described:
271-
272-
```raw graphql example
273-
"""
274-
A simple GraphQL schema which is well described.
275-
"""
276-
schema {
277-
query: Query
278-
}
279-
280-
"""
281-
Root type for all your query operations
282-
"""
283-
type Query {
284-
"""
285-
Translates a string from a given language into a different language.
286-
"""
287-
translate(
288-
"The original language that `text` is provided in."
289-
fromLanguage: Language
290-
291-
"The translated language to be returned."
292-
toLanguage: Language
293-
294-
"The text to be translated."
295-
text: String
296-
): String
297-
}
241+
descriptions on all named definitions in executable {Document} and GraphQL type
242+
systems, which is also made available via introspection ensuring the
243+
documentation of a GraphQL service remains consistent with its capabilities (see
244+
[Type System Descriptions](#sec-Type-System-Descriptions)).
298245

299-
"""
300-
The set of languages supported by `translate`.
301-
"""
302-
enum Language {
303-
"English"
304-
EN
305-
306-
"French"
307-
FR
308-
309-
"Chinese"
310-
CH
311-
}
312-
```
246+
GraphQL descriptions are expected to provided as Markdown (as specified by
247+
[CommonMark](https://commonmark.org/)). Description strings (often
248+
{BlockString}) occur immediately before the definition they describe.
313249

314-
This is an example of a well-described executable document:
250+
This is an example of a well-described operation:
315251

316252
```graphql example
317253
"""
@@ -343,26 +279,11 @@ fragment TimeMachineDetails on TimeMachine {
343279
}
344280
```
345281

346-
Descriptions are not permitted on the shorthand form of operations:
347-
348-
```graphql counter-example
349-
"This description is invalid, because this is a shorthand operation definition"
350-
{
351-
timeMachine(id: "TM-1985") {
352-
status
353-
destination {
354-
year
355-
location
356-
}
357-
}
358-
}
359-
```
360-
361-
Note: Descriptions and comments in executable GraphQL documents are purely for
282+
Descriptions and comments in executable GraphQL documents are purely for
362283
documentation purposes. They MUST NOT affect the execution, validation, or
363-
response of a GraphQL document except for type and schema introspection. It is
364-
otherwise safe to remove all descriptions and comments from executable documents
365-
without changing their behavior or results.
284+
response of a GraphQL document except for type introspection. It is otherwise
285+
safe to remove all descriptions and comments from executable documents without
286+
changing their behavior or results.
366287

367288
## Document
368289

@@ -457,6 +378,8 @@ For example, this unnamed query operation is written via query shorthand.
457378
}
458379
```
459380

381+
Descriptions are not permitted on query shorthand.
382+
460383
Note: many examples below will use the query short-hand syntax.
461384

462385
## Selection Sets

spec/Section 3 -- Type System.md

Lines changed: 56 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,62 @@ choose to only allow {TypeSystemExtensionDocument} and not allow
5252

5353
## Type System Descriptions
5454

55-
Documentation is a first-class feature of GraphQL type systems. GraphQL schema
56-
and all other definitions (e.g. types, fields, arguments, etc.) which can be
57-
described should provide a {Description} unless they are considered self
58-
descriptive.
59-
60-
Descriptions in the type system definition language occur immediately before the
61-
definition they describe and are made available via introspection, ensuring the
62-
documentation of a GraphQL service remains consistent with its capabilities.
63-
64-
Note: See Section 2, "Descriptions", for normative rules and syntax details.
65-
Type system descriptions follow the same Markdown format and rules as executable
66-
document descriptions.
55+
Documentation is a first-class feature of GraphQL type systems, written
56+
immediately alongside definitions in a {TypeSystemDocument} and made available
57+
via introspection.
58+
59+
[Descriptions](#sec-Descriptions) allow GraphQL service designers to easily
60+
provide documentation which remains consistent with the capabilities of a
61+
GraphQL service. Descriptions provided as Markdown (as specified by
62+
[CommonMark](https://commonmark.org/)) for every definition in a type system.
63+
64+
GraphQL schema and all other definitions (e.g. types, fields, arguments, etc.)
65+
which can be described should provide a {Description} unless they are considered
66+
self descriptive.
67+
68+
As an example, this simple GraphQL schema is well described:
69+
70+
```raw graphql example
71+
"""
72+
A simple GraphQL schema which is well described.
73+
"""
74+
schema {
75+
query: Query
76+
}
77+
78+
"""
79+
Root type for all your query operations
80+
"""
81+
type Query {
82+
"""
83+
Translates a string from a given language into a different language.
84+
"""
85+
translate(
86+
"The original language that `text` is provided in."
87+
fromLanguage: Language
88+
89+
"The translated language to be returned."
90+
toLanguage: Language
91+
92+
"The text to be translated."
93+
text: String
94+
): String
95+
}
96+
97+
"""
98+
The set of languages supported by `translate`.
99+
"""
100+
enum Language {
101+
"English"
102+
EN
103+
104+
"French"
105+
FR
106+
107+
"Chinese"
108+
CH
109+
}
110+
```
67111

68112
## Schema
69113

0 commit comments

Comments
 (0)