graphql-go
graphql-go copied to clipboard
Empty types should not be allowed
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)
}
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.
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