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

ObjectType, Input, Enum, and Interface Definitions should not be allowed with zero fields.

Open ssko1 opened this issue 4 years ago • 2 comments

Current

type Query {}
type Foo {}
input Bar {}
interface Qux {}
enum Quux {}

fails the following test

func TestMustHaveOneField(t *testing.T) {
	_, err := graphql.ParseSchema("type Query {} input Bar {} interface Qux {} enum Quux {}", nil)
	if err == nil {
		t.Fatal("types, inputs, interfaces and enums must have at least one field")
	}
}

Expected

Types, inputs, interfaces, and enums should be validated to ensure that there is at least one field.

Relevant specification links ObjectTypeDefinition validation: https://spec.graphql.org/draft/#sel-HAHZhCFBABABuBq9O InterfaceTypeDefinition validation: https://spec.graphql.org/draft/#sel-HAHbnBFBABABxB4a EnumTypeDefinition validation: https://spec.graphql.org/draft/#sel-HAHfVFBABAB4B_6J InputObjectTypeDefinition validation: https://spec.graphql.org/draft/#sel-HAHhBXDBABAB6BpkU

Environment

  • tested against the master branch

I'd be more than happy to contribute a fix.

ssko1 avatar Mar 25 '21 18:03 ssko1

There is a PR open for this issue: https://github.com/graph-gophers/graphql-go/pull/127, but it hasn't been touched in 2 years.

ssko1 avatar Mar 25 '21 18:03 ssko1

@ssko1 feel free to take it and resolve the conflicts

pavelnikolov avatar Apr 21 '21 08:04 pavelnikolov