Skip to content
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 defining empty types #630

Closed
steebchen opened this issue Mar 17, 2019 · 4 comments
Closed

Allow defining empty types #630

steebchen opened this issue Mar 17, 2019 · 4 comments
Labels
support please use https://discord.gg/DYEq3EMs4U for support questions

Comments

@steebchen
Copy link
Contributor

steebchen commented Mar 17, 2019

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.

@vektah
Copy link
Collaborator

vektah commented Mar 17, 2019

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 graphql/graphql-spec#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.

@vektah vektah closed this as completed Mar 17, 2019
@steebchen
Copy link
Contributor Author

Alright, makes sense

@steebchen
Copy link
Contributor Author

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

@vektah vektah added the support please use https://discord.gg/DYEq3EMs4U for support questions label May 15, 2019
@leventov
Copy link

@steebchen I still get an error:

OBJECT must define one or more fields.

gqlgen 0.11.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support please use https://discord.gg/DYEq3EMs4U for support questions
Projects
None yet
Development

No branches or pull requests

3 participants