Skip to content

Commit

Permalink
fix(deps) Replace uses of printSchema
Browse files Browse the repository at this point in the history
This is now part of the subgraph dependency and renamed to
printSubgraphSchema.
  • Loading branch information
Ian Mobley committed Oct 17, 2021
1 parent 827556c commit bf088f1
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 21 deletions.
27 changes: 16 additions & 11 deletions lib/federation/graphql-federation.factory.ts
Expand Up @@ -92,20 +92,25 @@ export class GraphQLFederationFactory {
private async generateSchema(
options: GqlModuleOptions,
): Promise<GraphQLSchema> {
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),
});

Expand Down
8 changes: 4 additions & 4 deletions lib/federation/graphql-federation.module.ts
Expand Up @@ -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;
Expand All @@ -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,
);
}
Expand Down
17 changes: 11 additions & 6 deletions lib/graphql-definitions.factory.ts
Expand Up @@ -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([
Expand All @@ -133,7 +138,7 @@ export class GraphQLDefinitionsFactory {
]);
const tsFile = await this.gqlAstExplorer.explore(
gql`
${printSchema(schema)}
${printSubgraphSchema(schema)}
`,
path,
outputAs,
Expand Down

0 comments on commit bf088f1

Please sign in to comment.