Gqlgen: Allow defining empty types

Created on 17 Mar 2019  路  3Comments  路  Source: 99designs/gqlgen

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 }

graphql-js also allows empty types.

support

Most helpful comment

Just as an addition if other users visit this issue: using type Mutation without the braces works. Didn't know about this until now!

All 3 comments

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cajax picture cajax  路  4Comments

msmedes picture msmedes  路  4Comments

bieber picture bieber  路  4Comments

huanghantao picture huanghantao  路  3Comments

imiskolee picture imiskolee  路  3Comments