Description
While using relay modern v1.5.0, I got the following when running relay-compiler (I promise this is a graphql issue):
ERROR:
Cannot read property 'some' of undefined
error An unexpected error occurred: "Command failed.
Exit code: 100
Note that the error has no stack trace!
The some
that it mentioned was:
function hasConcreteTypeThatImplements(schema, type, interfaceName) {
return isAbstractType(type) && getConcreteTypes(schema, type).some(function (concreteType) {
return implementsInterface(concreteType, interfaceName);
});
}
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
returned undefined
, 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 their rootSchema.types
.
Happy to PR if this sounds like a reasonable plan!