-
-
Notifications
You must be signed in to change notification settings - Fork 136
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
Can default values form cycles? #196
Comments
Thanks for the feedback @mat-sop. Let's first simplify the problematic SDL a bit to get to the core of it: """Example 1"""
type Query { field(recursiveInput: RecursiveInput): String }
input RecursiveInput {
self: RecursiveInput = {value: "foo"}
value: String
} The spec actually says something about such recursions here. Though it does not explicitly mention your example, the spirit of the spec is that recursive definitions are in principle allowed, but only if it is possible to construct valid values from them. This can be possible by breaking the chain with a null value if the definition allows that. The problem I see in this example is the default value of """Example 2"""
type Query { field(recursiveInput: RecursiveInput): String }
input RecursiveInput {
self: RecursiveInput
value: String
} However, the following also looks fine to me but still breaks: """Example 3"""
type Query { field(recursiveInput: RecursiveInput): String }
input RecursiveInput {
self: RecursiveInput = {value: "foo", self: null}
value: String
} On the other hand, the following actually invalid example does not give an error: """Example 4"""
type Query { field(recursiveInput: RecursiveInput): String }
input RecursiveInput {
self: RecursiveInput!
value: String
} I found that the same problems exists in graphql-js. which also throws a "Maximum call stack size exceeded" error in the cases where Python raises a RecursionError. Since the goal of graphql-core is to replicate graphql-js, I do not consider it a bug in graphql-core, but something that might need to be fixed in grapqhl-js. I currently see three things that could be improved here:
But this should be discussed in the issue tracker of GraphQL.js. I would be glad if you could create an issue there. Otherwise I will do it when I find some more time. |
Hi, I’ve been working with input fields' default values, and I encountered this question - can default values form cycles? I looked into the spec but I haven’t found answer. I tried to create a schema with such values:
I used
graphql-core==3.2.3
andpython-3.11.1
, as a result, I got this exception:I wonder if this is not allowed but not mentioned in the specification or is it a bug in
graphql-core
?The text was updated successfully, but these errors were encountered: