Skip to content

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

Open
thomas-advantitge wants to merge 4 commits into
masterfrom
fix/federation-resolvetype
Open

fix(federation): override federated resolveType for interfaces#1
thomas-advantitge wants to merge 4 commits into
masterfrom
fix/federation-resolvetype

Conversation

@thomas-advantitge
Copy link
Copy Markdown

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