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

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

Open
ssko1 opened this issue Mar 25, 2021 · 2 comments

Comments

@ssko1
Copy link

ssko1 commented Mar 25, 2021

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 ssko1 changed the title ObjectType, Input, and Interface Definitions should not be allowed with zero fields. ObjectType, Input, Enum, and Interface Definitions should not be allowed with zero fields. Mar 25, 2021
@ssko1
Copy link
Author

ssko1 commented Mar 25, 2021

There is a PR open for this issue: #127, but it hasn't been touched in 2 years.

@pavelnikolov
Copy link
Member

@ssko1 feel free to take it and resolve the conflicts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants