Empty types should be allowed. I'm not sure if the GraphQL spec allows this, but I think it makes sense when you extend types.
For example, when I have a complex schema and split my definitions into separate packages/files, I may want to do the following:
# query/query.graphqls
type Query {} # not allowed :(
# query/user/user.graphqls
extend type Query {
user: User!
}
type User {
name: String
}
The exact error message is modelgen: api/resolver/mutation/mutation.graphqls:1: expected at least one definition, found }
From the current and draft specs
An Object type must define one or more fields.
That issue has no merged PRs and people saying that it doesnt work in graphql-js
Lets wait for https://github.com/facebook/graphql/issues/568. If you are championing this please have a read of the graphql spec contribution guidelines. I cant imagine much resistance to this, it should go through pretty quickly.
Alright, makes sense
Just as an addition if other users visit this issue: using type Mutation without the braces works. Didn't know about this until now!
Most helpful comment
Just as an addition if other users visit this issue: using
type Mutationwithout the braces works. Didn't know about this until now!