graphql
graphql copied to clipboard
[Federation] interface implements other interfaces
Is there an existing issue for this?
- [X] I have searched the existing issues
Current behavior
When I run the server using code-first approach I get the following error. Using the schema-first approach it is working as expected.
/Users/laurent/users-application/node_modules/graphql/type/schema.js:219
throw new Error(
^
Error: Schema must contain uniquely named types but contains multiple types named "Entity".
at new GraphQLSchema (/Users/laurent/users-application/node_modules/graphql/type/schema.js:219:15)
at transformSchema (/Users/laurent/users-application/node_modules/@nestjs/graphql/dist/utils/transform-schema.util.js:22:12)
at GraphQLFederationFactory.overrideOrExtendResolvers (/Users/laurent/users-application/node_modules/@nestjs/graphql/dist/federation/graphql-federation.factory.js:101:60)
at GraphQLFederationFactory.generateSchema (/Users/laurent/users-application/node_modules/@nestjs/graphql/dist/federation/graphql-federation.factory.js:79:33)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at GraphQLFederationFactory.mergeWithSchema (/Users/laurent/users-application/node_modules/@nestjs/graphql/dist/federation/graphql-federation.factory.js:32:22)
at ApolloFederationDriver.start (/Users/laurent/users-application/node_modules/@nestjs/apollo/dist/drivers/apollo-federation.driver.js:19:32)
at GraphQLModule.onModuleInit (/Users/laurent/users-application/node_modules/@nestjs/graphql/dist/graphql.module.js:105:9)
at callModuleInitHook (/Users/laurent/users-application/node_modules/@nestjs/core/hooks/on-module-init.hook.js:51:9)
at NestApplication.callInitHook (/Users/laurent/users-application/node_modules/@nestjs/core/nest-application-context.js:178:13)
Minimum reproduction code
https://github.com/L-Luciano/graphql-federation-interface
Steps to reproduce
- npm i
- npm run start:dev
Expected behavior
server starts
Package version
10.0.19
Graphql version
"apollo-server-express": "3.9.0", "graphql": "16.5.0", "graphql-tools": "8.3.0",
"@apollo/federation": "0.36.1", "@apollo/gateway": "2.0.5", "@apollo/subgraph": "2.0.5",
NestJS version
9.0.1
Node.js version
v16.14.0
In which operating systems have you tested?
- [X] macOS
- [ ] Windows
- [ ] Linux
Other
Interfaces :
import { Field, ID, InterfaceType } from '@nestjs/graphql';
@InterfaceType()
export abstract class Entity {
@Field(() => ID)
id: number;
}
import { Field, InterfaceType } from '@nestjs/graphql';
import { Entity } from './entity.interface';
@InterfaceType({ implements: [Entity] })
export abstract class Person extends Entity {
@Field(() => String)
lastName: string;
@Field(() => String)
firstName: string;
}
Models :
@ObjectType({ implements: [Entity, Person] })
@Directive('@key(fields: "id")')
export class User extends Person {
@Field()
email: string;
}
This works with apollo-server packages.
No response
up 😄
Hey @L-Luciano did this merge https://github.com/nestjs/graphql/pull/2666 fixed your issue? try to upgrade nest/graphql to version 11
Yes, it looks like