For modularity, all my mutations use extend type Mutation. The problem is that somewhere I have to define type Mutation and it's not allowed to be empty (e.g. type Mutation {} is not allowed).
An easy workaround is to add a null mutation, type Mutation { null: Boolean }, but it would be nice to either omit type Mutation {...} or leave it empty, type Mutation {} ,when extend type Mutation exists.
The same applies for type Query.
Unfortunately this would allow you to produce invalid schema, which is something we've worked to prevent.
Since the type extension syntax is designed for client-side extension of schema, I'm not sure this is a typical use case that would warrant allowing for producing of invalid schema.
I'm closing this issue, but happy to continue conversation or hear other approaches which would not allow invalid schema to be produced.
Thanks for the comment. What if you only allow an empty type Mutation {} if extend type Mutation{...} exists? Would the following produce an invalid schema?
type Mutation {}
extend type Mutation {
someMutation($input: SomeInput!): SomePayload
}
As a best practices question, on the server side do you recommend having every mutation for the entire app inside of type Mutation {...} and not using extend at all? I've found it useful to keep the schema and resolvers for each part of my app together in the same place, and then merge the multiple schemas and resolvers in a centralized location.
Too bad this did not get an answer by @leebyron as this really matters when trying to modularize your app & GraphQL schema server-side.
@mxmlnglt We support empty object types since v0.12.0 just write type Mutation in SDL. Note: you should completely omit curly brackets since type Mutation {} is a syntax error. It would work with any type, interface, enum, enum, etc.
Most helpful comment
Thanks for the comment. What if you only allow an empty
type Mutation {}ifextend type Mutation{...}exists? Would the following produce an invalid schema?As a best practices question, on the server side do you recommend having every mutation for the entire app inside of
type Mutation {...}and not usingextendat all? I've found it useful to keep the schema and resolvers for each part of my app together in the same place, and then merge the multiple schemas and resolvers in a centralized location.