diff --git a/lib/federation/graphql-federation.factory.ts b/lib/federation/graphql-federation.factory.ts index 21aa623f2..ca8ee4221 100644 --- a/lib/federation/graphql-federation.factory.ts +++ b/lib/federation/graphql-federation.factory.ts @@ -73,13 +73,12 @@ export class GraphQLFederationFactory { } private buildSchemaFromTypeDefs(options: GqlModuleOptions) { - const { buildFederatedSchema } = loadPackage( - '@apollo/federation', - 'ApolloFederation', - () => require('@apollo/federation'), - ); + const { buildSubgraphSchema }: typeof import('@apollo/subgraph') = + loadPackage('@apollo/subgraph', 'ApolloFederation', () => + require('@apollo/subgraph'), + ); - return buildFederatedSchema([ + return buildSubgraphSchema([ { typeDefs: gql` ${options.typeDefs} @@ -92,12 +91,10 @@ export class GraphQLFederationFactory { private async generateSchema( options: GqlModuleOptions, ): Promise { - const { buildFederatedSchema } = loadPackage( - '@apollo/federation', - 'ApolloFederation', - () => require('@apollo/federation'), - ); - const { printSubgraphSchema } = loadPackage( + const { + buildSubgraphSchema, + printSubgraphSchema, + }: typeof import('@apollo/subgraph') = loadPackage( '@apollo/subgraph', 'ApolloFederation', () => require('@apollo/subgraph'), @@ -109,7 +106,7 @@ export class GraphQLFederationFactory { options, this.resolversExplorerService.getAllCtors(), ); - let executableSchema: GraphQLSchema = buildFederatedSchema({ + let executableSchema: GraphQLSchema = buildSubgraphSchema({ typeDefs: gql(printSubgraphSchema(autoGeneratedSchema)), resolvers: this.getResolvers(options.resolvers), }); diff --git a/lib/federation/graphql-federation.module.ts b/lib/federation/graphql-federation.module.ts index fb787d13e..668d7da78 100644 --- a/lib/federation/graphql-federation.module.ts +++ b/lib/federation/graphql-federation.module.ts @@ -142,11 +142,10 @@ export class GraphQLFederationModule implements OnModuleInit, OnModuleDestroy { if (!this.httpAdapterHost || !this.httpAdapterHost.httpAdapter) { return; } - const { printSubgraphSchema } = loadPackage( - '@apollo/subgraph', - 'ApolloFederation', - () => require('@apollo/subgraph'), - ); + const { printSubgraphSchema }: typeof import('@apollo/subgraph') = + loadPackage('@apollo/subgraph', 'ApolloFederation', () => + require('@apollo/subgraph'), + ); const { typePaths } = this.options; const typeDefs = diff --git a/lib/graphql-definitions.factory.ts b/lib/graphql-definitions.factory.ts index 70eac197f..dc8385fe9 100644 --- a/lib/graphql-definitions.factory.ts +++ b/lib/graphql-definitions.factory.ts @@ -116,19 +116,16 @@ export class GraphQLDefinitionsFactory { const typePathDefs = await this.gqlTypesLoader.mergeTypesByPaths(typePaths); const mergedTypeDefs = extend(typePathDefs, typeDefs); - const { buildFederatedSchema } = loadPackage( - '@apollo/federation', - 'ApolloFederation', - () => require('@apollo/federation'), - ); - - const { printSubgraphSchema } = loadPackage( + const { + buildSubgraphSchema, + printSubgraphSchema, + }: typeof import('@apollo/subgraph') = loadPackage( '@apollo/subgraph', 'ApolloFederation', () => require('@apollo/subgraph'), ); - const schema = buildFederatedSchema([ + const schema = buildSubgraphSchema([ { typeDefs: gql` ${mergedTypeDefs} diff --git a/lib/graphql-schema.builder.ts b/lib/graphql-schema.builder.ts index b0b6d6d38..422c782ec 100644 --- a/lib/graphql-schema.builder.ts +++ b/lib/graphql-schema.builder.ts @@ -115,7 +115,9 @@ export class GraphQLSchemaBuilder { } private loadFederationDirectives() { - const { federationDirectives } = loadPackage( + const { + federationDirectives, + }: typeof import('@apollo/subgraph/dist/directives') = loadPackage( '@apollo/subgraph/dist/directives', 'SchemaBuilder', () => require('@apollo/subgraph/dist/directives'), diff --git a/package.json b/package.json index 9cd9f22e3..d5bfa0db8 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,6 @@ "release": "release-it" }, "devDependencies": { - "@apollo/federation": "0.33.3", "@apollo/gateway": "0.42.3", "@apollo/subgraph": "0.1.2", "@commitlint/cli": "13.2.1", @@ -81,7 +80,6 @@ "ws": "8.2.3" }, "peerDependencies": { - "@apollo/federation": "^0.26.0 || ^0.27.0 || ^0.29.0 || ^0.33.0", "@apollo/gateway": "^0.29.0 || ^0.32.0 || ^0.33.0 || ^0.35.0 || ^0.38.0 || ^0.42.0", "@apollo/subgraph": "^0.1.2", "@nestjs/common": "^8.0.0", @@ -94,9 +92,6 @@ "ts-morph": "^11.0.3 || ^12.0.0" }, "peerDependenciesMeta": { - "@apollo/federation": { - "optional": true - }, "@apollo/gateway": { "optional": true },