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

owned types are marked as extension #3023

Open
developer239 opened this issue Jun 2, 2024 · 1 comment
Open

owned types are marked as extension #3023

developer239 opened this issue Jun 2, 2024 · 1 comment

Comments

@developer239
Copy link

Issue Description

I am trying to run MOST MINIMALISTIC gateway but I am running into false positive error when one of the dependencies is thinking that Use Objet type is "extension" type.

Error: A valid schema couldn't be composed. The following composition errors were found:
        [auth] Type "User" is an extension type, but there is no type definition for "User" in any subgraph.

Auth Module:

@ObjectType()
@Directive('@key(fields: "id")') // this line breaks the gateway
export class User {
  @Field((type) => ID)
  id: number

  @Field()
  name: string

  @Field()
  email: string
}

@Resolver(() => User)
export class UserResolver {
  constructor(private userService: UserService) {}

  @Query((returns) => [User])
  users() {
    return this.userService.findAll()
  }
}

@Module({
  imports: [
    WrappedConfigModule,
    HomeModule,
    GraphQLModule.forRoot<ApolloFederationDriverConfig>({
      driver: ApolloFederationDriver,
      playground: true,
      autoSchemaFile: true,
      introspection: true,
      plugins: [ApolloServerPluginInlineTrace()],
    }),
    UserModule,
  ],
})
export class AppModule {}

Events Module:

@ObjectType()
export class Event {
  @Field((type) => ID)
  id: number

  @Field()
  name: string

  @Field()
  description: string

  @Field(() => [Number])
  attendees: number[]
}

@Resolver(() => Event)
export class EventResolver {
  constructor(private eventService: EventService) {}

  @Query((returns) => [Event])
  events() {
    return this.eventService.findAll()
  }
}

@Module({
  imports: [
    WrappedConfigModule,
    HomeModule,
    GraphQLModule.forRoot<ApolloFederationDriverConfig>({
      driver: ApolloFederationDriver,
      playground: true,
      autoSchemaFile: true,
      introspection: true,
      plugins: [ApolloServerPluginInlineTrace()],
    }),
    EventModule,
  ],
})
export class AppModule {}

Gateway Module:

@Module({
  imports: [
    WrappedConfigModule,
    HomeModule,
    GraphQLModule.forRoot<ApolloGatewayDriverConfig>({
      driver: ApolloGatewayDriver,
      gateway: {
        supergraphSdl: new IntrospectAndCompose({
          subgraphs: [
            { name: 'auth', url: 'http://localhost:8080/graphql' },
            { name: 'events', url: 'http://localhost:8081/graphql' },
          ],
        }),
      },
    }),
  ],
})
export class AppModule {}

Link to Reproduction

https://github.com/developer239/nest-microservices-example/tree/v2

Reproduction Steps

  1. yarn install
  2. yarn dev (run run the services manually one by one)
@developer239
Copy link
Author

I decided to patch this file and call it a day. The bug is likely not caused here but by @Directive('@key(fields: "id")') directive - either the decorator is problematic or the underlying tech.

`--- node_modules/@apollo/federation-internals/dist/schemaUpgrader.js.bak    2024-06-03 14:05:31
+++ node_modules/@apollo/federation-internals/dist/schemaUpgrader.js    2024-06-03 14:05:54
@@ -286,7 +286,7 @@
                 return;
             }
         }
-        this.addError(error_1.ERRORS.EXTENSION_WITH_NO_BASE.err(`Type "${type}" is an extension type, but there is no type definition for "${type}" in any subgraph.`, { nodes: extensionAST }));
+        // this.addError(error_1.ERRORS.EXTENSION_WITH_NO_BASE.err(`Type "${type}" is an extension type, but there is no type definition for "${type}" in any subgraph.`, { nodes: extensionAST }));
     }
     preUpgradeValidations() {
         for (const type of this.schema.types()) {
`

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