-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Throw error if no possible concrete types found #1277
Comments
@mattkrick Sounds very reasonable to me 👍
|
Wow, thank you @IvanGoncharov that made the PR super easy! Spec:
|
@mattkrick Prevents you from writing without fields: interface NoFields {
} So it's different check. |
* Allow interfaces to have no implementors Reverts #1277, and implements spec removal from #459. While it's an open question whether this validation is good, we need to provide an upgrade path for schemas that currently do not satisfy this validation rule. * Update test to accept unimplemented interface
It is unclear whether the spec validation from graphql/graphql-spec#424 as implemented by #1277 is what we want to have for the GraphQL Schema long term. This RFC lets us explore that option more, to see whether the breaking schema change is the right path forward.
While using relay modern v1.5.0, I got the following when running relay-compiler (I promise this is a graphql issue):
Note that the error has no stack trace!
The
some
that it mentioned was:Ultimately, this was caused because when graphql built my schema, it crawled & found the GraphQLInterfaceType, but it didn't find the concrete types that implemented the interface.
This didn't throw an error in GraphQL; however, calling
schema.getPossibleTypes
returnedundefined
, which borked it in the compiler.While it'd be nice for relay-compiler to catch errors & include a stack trace, I think the real issue is that GraphQL allows an abstract type to exist without any concrete types!
I propose closing this hole by calling schema.getPossibleTypes for each abstract type when building the schema. if the result is
undefined
then throw a friendly error telling the user to add that concrete type to theirrootSchema.types
.Happy to PR if this sounds like a reasonable plan!
The text was updated successfully, but these errors were encountered: