Skip to content

Federation subgraphs skipping interface's resolveType on graphql-js schemas #3201

@juampynr

Description

@juampynr

Issue Description

If you use graphql-js to define a schema with an interface (GraphQLInterfaceType) and then buildSubgraphSchema to build a subgraph, interface's resolveType in the schema are not being copied over, which leads to the runtime error:

"Abstract type \"Character\" must resolve to an Object type at runtime for field \"Query.character\". Either the \"Character\" type should provide a \"resolveType\" function or each possible type should provide an \"isTypeOf\" function."

I created https://github.com/juampynr/subgraph-interface to illustrate this bug.

Link to Reproduction

https://github.com/juampynr/subgraph-interface

Reproduction Steps

Run the following commands to see the error:

git clone [email protected]:juampynr/subgraph-interface.git
cd subgraph-interface
nvm use
npm i
node index.js
curl --location 'http://localhost:4000/graphql' \
--header 'Content-Type: application/json' \
--data '{"query":"query {\n  character(id: \"1\") {\n    id\n    name\n    ... on Hero {\n      superpower\n    }\n    ... on Villain {\n      evilPlan\n    }\n  }\n}","variables":{}}'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions