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

fix(federation): override federated resolveType for interfaces #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

thomas-advantitge
Copy link

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Other... Please describe:

What is the current behavior?

Interfaces example (https://docs.nestjs.com/graphql/interfaces) with resolveType doesn't work when changing GraphQLModule to GraphQLFederationModule.

{
  "errors": [
    {
      "message": "Abstract type \"Party\" must resolve to an Object type at runtime for field \"Query.parties\". Either the \"Party\" type should provide a \"resolveType\" function or each possible type should provide an \"isTypeOf\" function.",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
...

Issue Number: N/A

What is the new behavior?

Resolve type function is executed when using GraphQLFederationModule.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

// lib/federation/graphql-federation.factory.ts

// autoGeneratedSchema is including types with resolveType function
const autoGeneratedSchema: GraphQLSchema = await this.gqlSchemaBuilder.buildFederatedSchema(
  options.autoSchemaFile,
  options,
  this.resolversExplorerService.getAllCtors(),
);
// executableSchema "erases" this field
let executableSchema: GraphQLSchema = buildFederatedSchema({
  typeDefs: gql(printSchema(autoGeneratedSchema)),
  resolvers: this.getResolvers(options.resolvers),
});

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

Successfully merging this pull request may close these issues.

1 participant