99import deepMerge from "lodash.merge" ;
1010import { buildSubgraphSchema } from "@apollo/subgraph" ;
1111import gql from "graphql-tag" ;
12- import { ApolloFederationDriver } from "@nestjs/apollo" ;
1312
1413import {
1514 TYPEGRAPHQL_ROOT_MODULE_OPTIONS ,
@@ -28,15 +27,15 @@ export default class TypeGraphQLOptionsFactory implements GqlOptionsFactory {
2827 ) { }
2928
3029 async createGqlOptions ( ) : Promise < GqlModuleOptions > {
31- const { globalMiddlewares, driver, federationVersion } =
32- this . rootModuleOptions ;
30+ const { globalMiddlewares, federationVersion } = this . rootModuleOptions ;
3331 const { resolversClasses, container, orphanedTypes, referenceResolvers } =
3432 this . optionsPreparatorService . prepareOptions (
3533 TYPEGRAPHQL_FEATURE_MODULE_OPTIONS ,
3634 globalMiddlewares ,
3735 ) ;
3836
39- const isFederatedModule = driver === ApolloFederationDriver ;
37+ const isFederatedModule =
38+ federationVersion === 1 || federationVersion === 2 ;
4039
4140 let schema = await buildSchema ( {
4241 ...this . rootModuleOptions ,
@@ -46,12 +45,6 @@ export default class TypeGraphQLOptionsFactory implements GqlOptionsFactory {
4645 } ) ;
4746
4847 if ( isFederatedModule ) {
49- if ( ! federationVersion ) {
50- throw new Error (
51- "You need to provide `federationVersion` option to `TypeGraphQLModule.forRoot()` when using `ApolloFederationDriver`" ,
52- ) ;
53- }
54-
5548 // build Apollo Subgraph schema
5649 const federatedSchema = buildSubgraphSchema ( {
5750 typeDefs : gql ( printSubgraphSchema ( schema , federationVersion ) ) ,
0 commit comments