Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add schema validation: Input Objects must not contain non-nullable circular references #492

Merged
merged 4 commits into from Jun 12, 2019
Merged

Add schema validation: Input Objects must not contain non-nullable circular references #492

merged 4 commits into from Jun 12, 2019

Conversation

spawnia
Copy link
Collaborator

@spawnia spawnia commented Jun 10, 2019

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
}

Spec change: graphql/graphql-spec#445
Reference implementation: graphql/graphql-js#1359

I think this might be added to a 0.13 release, since the relevant spec change is just a clarification.

@vladar
Copy link
Member

vladar commented Jun 12, 2019

That's great, thanks!

@spawnia spawnia deleted the circular-references branch June 12, 2019 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants