Skip to content

Commit

Permalink
Add rules for how circular references in Input Objects are handled gr…
Browse files Browse the repository at this point in the history
  • Loading branch information
spawnia committed May 16, 2018
1 parent 06614fb commit 39227d5
Showing 1 changed file with 50 additions and 4 deletions.
54 changes: 50 additions & 4 deletions spec/Section 3 -- Type System.md
Original file line number Diff line number Diff line change
Expand Up @@ -1360,11 +1360,57 @@ Literal Value | Variables | Coerced Value

**Type Validation**

1. An Input Object type must define one or more input fields.
2. The fields of an Input Object type must have unique names within that
Input Object type; no two fields may share the same name.
3. The return types of each defined field must be an Input type.
* An Input Object type must define one or more input fields.
* The fields of an Input Object type must have unique names within that
Input Object type; no two fields may share the same name.
* The return types of each defined field must be an Input type.

Input Objects are generally allowed to reference other Input Objects, even itself.
If an Input Object references itself either directly or through subordinated
Input Objects, one of the fields in the chain of references must be either nullable
or a list. Input Objects with non-nullable circular references are invalid, because there
is no way to provide a legal value for them.

The following examples are allowed:

```graphql example
input Example {
value: String
self: Example
}
```

This is fine because `self` may simply omitted at any point in the chain.

```graphql example
input Example {
value: String
self: [Example!]!
}
```

This also works as `self` can just contain an empty list.

The following examples are invalid:

```graphql counter-example
input Example {
value: String
self: Example!
}
```

```graphql counter-example
input First {
second: Second!
string: String
}

input Second {
second: Second!
string: String
}
```

### Input Object Extensions

Expand Down

0 comments on commit 39227d5

Please sign in to comment.