File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
packages/graphql/lib/federation Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -94,7 +94,13 @@ export class GraphQLFederationFactory {
94
94
'ApolloFederation' ,
95
95
( ) => require ( '@apollo/subgraph' ) ,
96
96
) ;
97
+ const apolloSubgraphVersion = loadPackage (
98
+ '@apollo/subgraph' ,
99
+ 'ApolloFederation' ,
100
+ ( ) => require ( '@apollo/subgraph/package.json' ) ,
101
+ ) ;
97
102
103
+ const isaApolloSubgraph2 = Number ( apolloSubgraphVersion . split ( '.' ) [ 0 ] ) >= 2 ;
98
104
const printSubgraphSchema = apolloSubgraph . printSubgraphSchema ;
99
105
100
106
if ( ! buildFederatedSchema ) {
@@ -106,7 +112,9 @@ export class GraphQLFederationFactory {
106
112
options ,
107
113
this . resolversExplorerService . getAllCtors ( ) ,
108
114
) ;
109
- let typeDefs = printSchemaWithDirectives ( autoGeneratedSchema ) ;
115
+ let typeDefs = isaApolloSubgraph2
116
+ ? printSchemaWithDirectives ( autoGeneratedSchema )
117
+ : printSubgraphSchema ( autoGeneratedSchema ) ;
110
118
if ( options . useFed2 ) {
111
119
const {
112
120
directives = [
You can’t perform that action at this time.
0 commit comments