graph-gophers / graphql-go

GraphQL server with a focus on ease of use
BSD 2-Clause "Simplified" License
4.65k stars 492 forks source link

Empty types should not be allowed #209

Open nonpop opened 6 years ago

nonpop commented 6 years ago

According to the GraphQL specification both object types and input types should have at least one field. See here and here. So, the following program should crash saying something about empty types. Currently graphql-go just lets it through.

package main

import graphql "github.com/graph-gophers/graphql-go"

func main() {
    graphql.MustParseSchema("type Foo{}", nil)
}
robsdedude commented 5 years ago

Don't be to quick there ;) https://github.com/graphql/graphql-js/issues/937

As I understood, type Foo{} is indeed invalid, but type Foo is fine.

robsdedude commented 5 years ago

Ok, I'll take that back. It's not ok as per the specs (as @nonpop wrote). How ever I'd suggest to keep it as is, as empty types are very useful (see my the linked issue).

Also it might well happen soon that it's ok to have empty types: https://github.com/graphql/graphql-spec/issues/568