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

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

Open
juampynr opened this issue Jan 15, 2025 · 1 comment

Comments

@juampynr
Copy link

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":{}}'
@juampynr
Copy link
Author

Fixed this issue by restoring the interfaces resolveType handlers after the subgraph has been built: juampynr/subgraph-interface#1.

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

No branches or pull requests

1 participant