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

refactor(InterfaceType) determine possible_types based on the schema #142

Merged
merged 1 commit into from
Apr 27, 2016

Conversation

rmosolgo
Copy link
Owner

Taking a cue from graphql/graphql-js#327

Previously, InterfaceType#possible_types was implemented as an array which was mutated for every object that implemented it. This caused bugs and resulted in complex gem code.

So instead, determine possible types within the schema. This will fix some nasty bugs, support Rails development better, and remove the lingering caveat when people ask "can you make multiple schemas".

The downer is that it's a breaking change: any orphan type must be passed to types: (where previously it was discovered at load-time).

Before shipping this change, I'll push a minor version with deprecation warnings.

@theorygeek
Copy link
Contributor

Nice change! So it sounds like specifically, if your schema has an object type that is only used indirectly (ie, it is a possible type for an interface or union, but is never itself the declared type for any field in the schema), you need to pass it to the types: parameter when you call GraphQL::Schema#new.

Is that right?

@rmosolgo
Copy link
Owner Author

Yes, with one clarification:

used indirectly (ie, it is a possible type for an interface or union)

Unions are ok as-is because they access their possible types during definition, which causes Rails to load those constants.

But interfaces have the problem because they dont cause their members to be loaded by Rails. Instead, those types are loaded sometime later or not at all... and mayhem ensues!

@rmosolgo rmosolgo merged commit f70b9d9 into master Apr 27, 2016
@rmosolgo rmosolgo deleted the schema-interfaces branch April 27, 2016 01:03
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

Successfully merging this pull request may close these issues.

None yet

2 participants