From bf088f1eb5888fb78b3d6b9e83db2acb4255bc61 Mon Sep 17 00:00:00 2001 From: Ian Mobley Date: Sat, 16 Oct 2021 09:32:06 -0700 Subject: [PATCH] fix(deps) Replace uses of printSchema This is now part of the subgraph dependency and renamed to printSubgraphSchema. --- lib/federation/graphql-federation.factory.ts | 27 ++++++++++++-------- lib/federation/graphql-federation.module.ts | 8 +++--- lib/graphql-definitions.factory.ts | 17 +++++++----- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/lib/federation/graphql-federation.factory.ts b/lib/federation/graphql-federation.factory.ts index 482eb5286..4999169d3 100644 --- a/lib/federation/graphql-federation.factory.ts +++ b/lib/federation/graphql-federation.factory.ts @@ -92,20 +92,25 @@ export class GraphQLFederationFactory { private async generateSchema( options: GqlModuleOptions, ): Promise { - const { - buildFederatedSchema, - printSchema, - } = loadPackage('@apollo/federation', 'ApolloFederation', () => - require('@apollo/federation'), + const { buildFederatedSchema } = loadPackage( + '@apollo/federation', + 'ApolloFederation', + () => require('@apollo/federation'), ); - - const autoGeneratedSchema: GraphQLSchema = await this.gqlSchemaBuilder.buildFederatedSchema( - options.autoSchemaFile, - options, - this.resolversExplorerService.getAllCtors(), + const { printSubgraphSchema } = loadPackage( + '@apollo/subgraph', + 'ApolloFederation', + () => require('@apollo/subgraph'), ); + + const autoGeneratedSchema: GraphQLSchema = + await this.gqlSchemaBuilder.buildFederatedSchema( + options.autoSchemaFile, + options, + this.resolversExplorerService.getAllCtors(), + ); let executableSchema: GraphQLSchema = buildFederatedSchema({ - typeDefs: gql(printSchema(autoGeneratedSchema)), + 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 ca2dd4f18..fb787d13e 100644 --- a/lib/federation/graphql-federation.module.ts +++ b/lib/federation/graphql-federation.module.ts @@ -142,10 +142,10 @@ export class GraphQLFederationModule implements OnModuleInit, OnModuleDestroy { if (!this.httpAdapterHost || !this.httpAdapterHost.httpAdapter) { return; } - const { printSchema } = loadPackage( - '@apollo/federation', + const { printSubgraphSchema } = loadPackage( + '@apollo/subgraph', 'ApolloFederation', - () => require('@apollo/federation'), + () => require('@apollo/subgraph'), ); const { typePaths } = this.options; @@ -161,7 +161,7 @@ export class GraphQLFederationModule implements OnModuleInit, OnModuleDestroy { if (this.options.definitions && this.options.definitions.path) { await this.graphqlFactory.generateDefinitions( - printSchema(apolloOptions.schema), + printSubgraphSchema(apolloOptions.schema), this.options, ); } diff --git a/lib/graphql-definitions.factory.ts b/lib/graphql-definitions.factory.ts index 668642e7a..70eac197f 100644 --- a/lib/graphql-definitions.factory.ts +++ b/lib/graphql-definitions.factory.ts @@ -116,11 +116,16 @@ export class GraphQLDefinitionsFactory { const typePathDefs = await this.gqlTypesLoader.mergeTypesByPaths(typePaths); const mergedTypeDefs = extend(typePathDefs, typeDefs); - const { - buildFederatedSchema, - printSchema, - } = loadPackage('@apollo/federation', 'ApolloFederation', () => - require('@apollo/federation'), + const { buildFederatedSchema } = loadPackage( + '@apollo/federation', + 'ApolloFederation', + () => require('@apollo/federation'), + ); + + const { printSubgraphSchema } = loadPackage( + '@apollo/subgraph', + 'ApolloFederation', + () => require('@apollo/subgraph'), ); const schema = buildFederatedSchema([ @@ -133,7 +138,7 @@ export class GraphQLDefinitionsFactory { ]); const tsFile = await this.gqlAstExplorer.explore( gql` - ${printSchema(schema)} + ${printSubgraphSchema(schema)} `, path, outputAs,