-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Allow empty object type _extensions_ in schema #1106
Comments
Thanks for opening this @ychescale9! @benjie I'd argue this issue is slightly different from #568: #568 is about empty types and this issue is about empty exensions. #568 is probably a more fundamental change to the GraphQL type system. I see this issue as mainly about tooling. It doesn't change how the types are represented. Unions are still a thing and objects are required to have one or more fields. Just for convenience, we would allow extensions to be empty. That is a much smaller lift than #568. Can we keep it open with |
We already allow I'm pretty sure this parses, though I haven't checked: type Query {
meaningOfLife: Int
}
extend type Query |
Agreed, I think the intent here is facilitating copy/pasting full lines. I see this a bit as trailing comma quality of life improvement. Doesn't really change the language but makes it easier to work with the documents on a daily basis. It also minimizes the diff if you were to commit those files, etc... It's not essential but I would support the change unless there are strong reasons not to do so that I'm not thinking about today. |
@martinbonnin FYI with Apollo Kotlin just having |
Yikes, let me double check. Just to make sure: is there anything before that |
Just tested again: this is the entire document:
Result:
|
Turns out See https://spec.graphql.org/draft/#ObjectTypeExtension, the spec mandates that the extension adds at least a directive, a field or an interface. |
That makes sense; |
That's the billion dollar question. My initial thoughts are that parsers are written by few people (dozens?) but used by many more (thousands? millions?). So the price to pay for the maintainers is amortized on a lot of potential users. Now it all depends how many users would actually benefit from this feature... #tradeoffs |
I have been told by @martinbonnin that the following isn't supposed to work according to the spec:
However being able to have empty type definitions is useful sometimes where a local "stub" schema needs to be changed between empty and non-empty frequently as part of the dev workflow.
Specifically the use case for us is that we have a local
stub.graphqls
schema alongside the remote schema we download from the backend. Our devs sometimes add types to thestubs.graphqls
while waiting for the changes to be deployed to the real schema (we try to avoid manually tempering the real schema). So about half of the time the content of theextend type Query
is empty.A similar use case can be found here.
The text was updated successfully, but these errors were encountered: