Skip to content

Commit 02fa661

Browse files
committed
resolves confusion around type definition invalid
1 parent 828ecd0 commit 02fa661

File tree

1 file changed

+39
-7
lines changed

1 file changed

+39
-7
lines changed

spec/Section 4 -- Composition.md

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,18 +188,32 @@ ERROR
188188
- Let {types} be the set of built-in types (for example, `FieldSelectionMap`)
189189
defined by the composition specification from the schema.
190190
- For each {type} in {types}:
191-
- {type} must strictly equal the built-in type defined by the composition
192-
specification.
191+
- Let {kind} be the kind of {type}.
192+
- {kind} must be equal to the kind defined by the composition specification.
193+
- If {type} is a directive:
194+
- Let {expectedArguments} be the set of arguments defined by the composition
195+
specification.
196+
- For each {expectedArgument} in {expectedArguments}:
197+
- Let {name} be the name of {expectedArgument}.
198+
- Let {argument} be the argument with {name} in {type}.
199+
- {argument} must be defined.
200+
- Let {expectedType} be the type of {expectedArgument}.
201+
- Let {type} be the type of {argument}.
202+
- {type} must be equal to {expectedType}.
193203

194204
**Explanatory Text**
195205

196-
Certain types are reserved in composite schema specification for specific
197-
purposes and must adhere to the specification's definitions. For example,
198-
`FieldSelectionMap` is a built-in scalar that represents a selection of fields
199-
as a string. Redefining these built-in types with a different kind (e.g., an
200-
input object, enum, union, or object type) is disallowed and makes the
206+
Certain types (and directives) are reserved in composite schema specification
207+
for specific purposes and must adhere to the specification's definitions. For
208+
example, `FieldSelectionMap` is a built-in scalar that represents a selection of
209+
fields as a string. Redefining these built-in types with a different kind (e.g.,
210+
an input object, enum, union, or object type) is disallowed and makes the
201211
composition invalid.
202212

213+
To ensure schema evolution and interoperability, directives may include
214+
additional arguments, provided that all required arguments defined by the
215+
specification are present.
216+
203217
This rule ensures that built-in types maintain their expected shapes and
204218
semantics so the composed schema can correctly interpret them.
205219

@@ -218,6 +232,24 @@ input FieldSelectionMap {
218232
}
219233
```
220234

235+
In the following example, the `@key` directive includes an additional argument,
236+
`futureArg`, which is not part of the specification. This is valid and allows
237+
the directive to evolve without breaking existing schemas.
238+
239+
```graphql example
240+
directive @key(
241+
fields: SelectionSet!
242+
futureArg: String
243+
) repeatable on OBJECT | INTERFACE
244+
```
245+
246+
However, if the `@key` directive is defined without the required `fields`
247+
argument, as shown below, it results in a `TYPE_DEFINITION_INVALID` error.
248+
249+
```graphql counter-example
250+
directive @key(futureArg: String) repeatable on OBJECT | INTERFACE
251+
```
252+
221253
#### Query Root Type Inaccessible
222254

223255
**Error Code**

0 commit comments

Comments
 (0)