Skip to content

Add null check to getAllImplementsInterfaceNodes() #2154

Open
@saerdnaer

Description

With some faulty schemas or responses iface in the following section can be null:

function getAllImplementsInterfaceNodes(
type: GraphQLObjectType,
iface: GraphQLInterfaceType,
): $ReadOnlyArray<NamedTypeNode> {
return getAllSubNodes(type, typeNode => typeNode.interfaces).filter(
ifaceNode => ifaceNode.name.value === iface.name,
);
}

If fails then with [error] Cannot read property 'name' of null. Adding a null check yields the much more understandable error message
Type $typename must only implement Interface types, it cannot implement null.

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions