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

Missing errors on invalid types in development #136

Closed
dphaener opened this issue Apr 13, 2016 · 4 comments
Closed

Missing errors on invalid types in development #136

dphaener opened this issue Apr 13, 2016 · 4 comments

Comments

@dphaener
Copy link

If a type is not defined correctly, i.e.: field :name, "This is missing a type argument" the app will run fine in development with no errors as long as the type is not queried. In production however, all queries will fail (rightly so).

FWIW I am using Puma in production and pre-loading the app. Here is a small Rails app that reproduces the problem: https://github.com/dphaener/graphql-test

@rmosolgo
Copy link
Owner

Ohhh I see ... this is tough.

Firstly, a String is a valid entry for field type. It gets looked up in the global namespace to find the type object.

Secondly, type resolution starts with QueryType & MutationType and follows the tree, going from field to field, finding all the types included in the schema. So any types which aren't connected to those roots (like BreweryType in the example) aren't found during that search 😢

Options? Hm...

A types: argument would also with not mutating InterfaceTypes.

@dphaener
Copy link
Author

I think providing some help loading the graph directory is a great idea. I've had issues surrounding loading all the type definitions in the right order, it can get a bit hairy with a larger application. If they're all preloaded, something like this would definitely cause an error I think.

As far as the types argument goes. Does this end up enforcing a strict set of types that can be used in the schema?

@rmosolgo
Copy link
Owner

rmosolgo commented Apr 29, 2016

strict set of types?

No, it's just a way to add additional types which can't be discovered by crawling fields from the schema roots. (Specifically, that's types who are only connected to the schema because they're members of an interface.)

@rmosolgo
Copy link
Owner

I think I've done all I can here: "floating" types can (must) be added with types: and types are validated as soon as you use Schema.define, so these errors will appear in development, too!

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