graphql-go icon indicating copy to clipboard operation
graphql-go copied to clipboard

Empty types should not be allowed

Open nonpop opened this issue 6 years ago • 2 comments

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)
}

nonpop avatar May 15 '18 11:05 nonpop

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 avatar Sep 14 '19 13:09 robsdedude

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

robsdedude avatar Sep 14 '19 13:09 robsdedude