Repository navigation
Conversation
✅ Deploy Preview for graphql-spec-draft ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
When thinking about what can be left out of an input type, all required fields must be retained. Consider: input Foo {
a: Int
b: Int!
c: Int = 1
d: Int! = 1
e: [Int!]
f: [Int!]! = []
}this could compress down to: input Foo {
b: Int!
}but representing it as an empty input object would be invalid, a value could not be fed to that argument that the underlying schema (with all the input fields) would accept. (Solved: feedback on PR description)Incidentally the argument around your example: type Query {
issues(filter: IssueFilter): [Issue!]!
}
doesn't quite hold because it can be mapped by dropping the type Query {
issues: [Issue!]!
}Maybe you meant |
|
I think something went wrong with GitHub, some of the comments from my review posted but others remained "pending". I've submitted the review again, but now it looks like there might be duplicates... I'm not going to delete them in case that causes more headaches 😅 |
This comment was marked as resolved.
This comment was marked as resolved.
75a1a62 to
4a971fe
Compare
Follow up to:
Today, an input object type must define at least one input field. This proposal removes that requirement, making
input Filter {}a valid definition. It follows the approach the Nov 5 Working Group agreed for #1228:{}defines an empty type, and a bareinput Filterstays incomplete until an extension completes it.The motivation comes from the Schema Search RFC (graphql/ai-wg#187). It describes a service that returns a valid subset of its schema as SDL in response to a natural language query. A slice may omit optional arguments and optional input fields, but it must keep the required ones. Take this excerpt of a full schema:
For a question like "list the issue titles", the slice must keep
filterbecause it is required, so it must also defineIssueFilter. All of its fields are optional and none matter to the question, so the slice leaves it empty:The model can then send
issues(filter: {}), which is also valid against the full schema.Under the current rule, this slice is invalid. The slicer has to either drop the
issuesfield, hiding the entry point, or keep an input field the question does not need. Keeping one also pulls in its type:If that field were another input object, its fields would follow too. This change lets the slice keep the reference with an empty definition, and the model can request
IssueFilterlater if it needs to filter.It also removes one more reason a schema with all deprecated elements removed can become invalid, as mentioned in #1228 (comment).
GraphQL.js implementation: graphql/graphql-js#4934