Disallow non-breakable chains of circular references in Input Objects
At a glance​
- Identifier: #445
- Stage: RFCX: Closed 2020-03-24T08:47:58Z
- Champion: @spawnia
- PR: Disallow non-breakable chains of circular references in Input Objects
- Related:
- #701 (Disallow non-breakable chains of circular references in Input Objects)
Timeline​
- Added to 2019-11-07 WG agenda
- Mentioned in 2019-11-07 WG notes
- Added to 2019-10-10 WG agenda
- Mentioned in 2019-10-10 WG notes
- Spec PR created on 2018-05-16 by spawnia
This was already discussed in Issue #189
Input Objects are allowed to reference other Input Objects. A circular reference occurs when an Input Object references itself either directly or through subordinated Input Objects.
Circular references are generally allowed, however they may not be defined as an unbroken chain of Non-Null fields. Such Input Objects are invalid, because there is no way to provide a legal value for them.
The following examples are allowed:
input Example {
self: Example
value: String
}This is fine because a value for
self
may simply be omitted from the arguments.input Example {
self: [Example!]!
value: String
}This also works as
self
can just contain an empty list.The following examples are invalid:
input Example {
value: String
self: Example!
}input First {
second: Second!
value: String
}
input Second {
first: First!
value: String
}The following example shows why no possible value can be provided:
{
someField(input: {
value: "val"
# self is required
self: {
value: "nextval"
# self is still required
self: {
# We would have to recurse down infinitely
...
}
}
})
}