diff --git a/spec/Section 3 -- Type System.md b/spec/Section 3 -- Type System.md index 8940956f7..f4cfa9746 100644 --- a/spec/Section 3 -- Type System.md +++ b/spec/Section 3 -- Type System.md @@ -96,6 +96,9 @@ type Query { } ``` +Note: A `query` root operation type which does not define any fields still +allows for [Schema Introspection](#sec-Schema-Introspection). + Similarly, the following mutation is valid if a `mutation` root operation type has a field named "setName". Note that the `query` and `mutation` root types must be different types. @@ -792,8 +795,7 @@ Objects are never valid inputs. Object types have the potential to be invalid if incorrectly defined. This set of rules must be adhered to by every Object type in a GraphQL schema. -1. An Object type must define one or more fields. -2. For each field of an Object type: +1. For each field of an Object type: 1. The field must have a unique name within that Object type; no two fields may share the same name. 2. The field must not have a name which begins with the @@ -804,8 +806,8 @@ of rules must be adhered to by every Object type in a GraphQL schema. characters {"__"} (two underscores). 2. The argument must accept a type where {IsInputType(argumentType)} returns {true}. -4. An object type may declare that it implements one or more unique interfaces. -5. An object type must be a super-set of all interfaces it implements: +2. An object type may declare that it implements one or more unique interfaces. +3. An object type must be a super-set of all interfaces it implements: 1. The object type must include a field of the same name for every field defined in an interface. 1. The object field must be of a type which is equal to or a sub-type of @@ -1052,8 +1054,7 @@ Interfaces are never valid inputs. Interface types have the potential to be invalid if incorrectly defined. -1. An Interface type must define one or more fields. -2. For each field of an Interface type: +1. For each field of an Interface type: 1. The field must have a unique name within that Interface type; no two fields may share the same name. 2. The field must not have a name which begins with the @@ -1402,16 +1403,17 @@ Literal Value | Variables | Coerced Value `$var` | `{ var: "abc123" } }` | Error: Incorrect value `{ a: "abc", b: "123" }` | `{}` | Error: Incorrect value for field {b} `{ a: "abc" }` | `{}` | Error: Missing required field {b} -`{ b: $var }` | `{}` | Error: Missing required field {b}. +`{ b: $var }` | `{}` | Error: Missing required field {b} +`{ }` | `{}` | Error: Missing required field {b} `$var` | `{ var: { a: "abc" } }` | Error: Missing required field {b} +`$var` | `{ var: { } }` | Error: Missing required field {b} `{ a: "abc", b: null }` | `{}` | Error: {b} must be non-null. `{ b: $var }` | `{ var: null }` | Error: {b} must be non-null. `{ b: 123, c: "xyz" }` | `{}` | Error: Unexpected field {c} **Type Validation** -1. An Input Object type must define one or more input fields. -2. For each input field of an Input Object type: +1. For each input field of an Input Object type: 1. The input field must have a unique name within that Input Object type; no two input fields may share the same name. 2. The input field must not have a name which begins with the diff --git a/spec/Section 4 -- Introspection.md b/spec/Section 4 -- Introspection.md index 9418a3b7c..c7e6eb446 100644 --- a/spec/Section 4 -- Introspection.md +++ b/spec/Section 4 -- Introspection.md @@ -98,6 +98,8 @@ identify which actual type of the possible types has been returned. This field is implicit and does not appear in the fields list in any defined type. +Note: The `__typename` field can always be queried, even if an Object or Interface does not define any fields. + ## Schema Introspection