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

Enum inside a InputObject #382

Closed
glaslos opened this issue Aug 21, 2018 · 3 comments
Closed

Enum inside a InputObject #382

glaslos opened this issue Aug 21, 2018 · 3 comments

Comments

@glaslos
Copy link

glaslos commented Aug 21, 2018

I have an issue with using a Enum type in an InputObject type:

var filterInputType = graphql.NewInputObject(graphql.InputObjectConfig{
	Name: "filterInput",
	Fields: graphql.InputObjectConfigFieldMap{
		"status": &graphql.InputObjectFieldConfig{
			Type:        statusEnum,
			Description: "status enum",
		},
	},
})
var statusEnum = graphql.NewEnum(graphql.EnumConfig{
	Name: "Status Enum",
	Values: graphql.EnumValueConfigMap{
		"PENDING": &graphql.EnumValueConfig{
			Value: 0,
		},
		"DONE": &graphql.EnumValueConfig{
			Value: 1,
		},
	},
})

Compiling this works but the Schema in the playground complains: Uncaught Error: Invalid or incomplete schema, unknown type: . Ensure that a full introspection query is used in order to build a client schema.

@bhoriuchi
Copy link
Contributor

I ran into this issue as well. I got around it by adding the type to the schema config

schemaConfig := graphql.SchemaConfig{
    Query:    rootQuery,
    Mutation: rootMutation,
    Types: []graphql.Type{
        statusEnum,
        filterInputType,
    },
}

@evulse
Copy link

evulse commented Oct 9, 2018

I thought this was odd as I'm using Enum's the same way as you without issues, however noticed you have a space in your name "Status Enum", I can confirm this causes the issue you mentioned if I apply a space to any of my usages. If you remove it and call it "StatusEnum" you should be fine.

@glaslos
Copy link
Author

glaslos commented Oct 9, 2018

Thanks 🤦‍♀️ your response should have been the error message...

@glaslos glaslos closed this as completed Oct 9, 2018
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

3 participants