@@ -11,6 +11,7 @@ import {
11
11
selectionSetSerializer ,
12
12
} from '../../snapshotSerializers' ;
13
13
import { normalizeTypeDefs } from '../normalize' ;
14
+ import { getFederationMetadata } from '../utils' ;
14
15
15
16
expect . addSnapshotSerializer ( astSerializer ) ;
16
17
expect . addSnapshotSerializer ( typeSerializer ) ;
@@ -59,8 +60,8 @@ describe('composeServices', () => {
59
60
const product = schema . getType ( 'Product' ) as GraphQLObjectType ;
60
61
const user = schema . getType ( 'User' ) as GraphQLObjectType ;
61
62
62
- expect ( product . federation . serviceName ) . toEqual ( 'serviceA' ) ;
63
- expect ( user . federation . serviceName ) . toEqual ( 'serviceB' ) ;
63
+ expect ( getFederationMetadata ( product ) . serviceName ) . toEqual ( 'serviceA' ) ;
64
+ expect ( getFederationMetadata ( user ) . serviceName ) . toEqual ( 'serviceB' ) ;
64
65
} ) ;
65
66
66
67
it ( "doesn't leave federation directives in the final schema" , ( ) => {
@@ -115,8 +116,8 @@ describe('composeServices', () => {
115
116
116
117
const product = schema . getType ( 'Product' ) as GraphQLObjectType ;
117
118
118
- expect ( product . federation . serviceName ) . toEqual ( 'serviceA' ) ;
119
- expect ( product . getFields ( ) [ 'price' ] . federation . serviceName ) . toEqual (
119
+ expect ( getFederationMetadata ( product ) . serviceName ) . toEqual ( 'serviceA' ) ;
120
+ expect ( getFederationMetadata ( product . getFields ( ) [ 'price' ] ) . serviceName ) . toEqual (
120
121
'serviceB' ,
121
122
) ;
122
123
} ) ;
@@ -154,8 +155,8 @@ describe('composeServices', () => {
154
155
155
156
const product = schema . getType ( 'Product' ) as GraphQLObjectType ;
156
157
157
- expect ( product . federation . serviceName ) . toEqual ( 'serviceB' ) ;
158
- expect ( product . getFields ( ) [ 'price' ] . federation . serviceName ) . toEqual (
158
+ expect ( getFederationMetadata ( product ) . serviceName ) . toEqual ( 'serviceB' ) ;
159
+ expect ( getFederationMetadata ( product . getFields ( ) [ 'price' ] ) . serviceName ) . toEqual (
159
160
'serviceA' ,
160
161
) ;
161
162
} ) ;
@@ -208,11 +209,11 @@ describe('composeServices', () => {
208
209
209
210
const product = schema . getType ( 'Product' ) as GraphQLObjectType ;
210
211
211
- expect ( product . federation . serviceName ) . toEqual ( 'serviceB' ) ;
212
- expect ( product . getFields ( ) [ 'price' ] . federation . serviceName ) . toEqual (
212
+ expect ( getFederationMetadata ( product ) . serviceName ) . toEqual ( 'serviceB' ) ;
213
+ expect ( getFederationMetadata ( product . getFields ( ) [ 'price' ] ) . serviceName ) . toEqual (
213
214
'serviceA' ,
214
215
) ;
215
- expect ( product . getFields ( ) [ 'color' ] . federation . serviceName ) . toEqual (
216
+ expect ( getFederationMetadata ( product . getFields ( ) [ 'color' ] ) . serviceName ) . toEqual (
216
217
'serviceC' ,
217
218
) ;
218
219
} ) ;
@@ -269,8 +270,8 @@ describe('composeServices', () => {
269
270
}
270
271
` ) ;
271
272
272
- expect ( product . federation . serviceName ) . toEqual ( 'serviceB' ) ;
273
- expect ( product . getFields ( ) [ 'price' ] . federation . serviceName ) . toEqual (
273
+ expect ( getFederationMetadata ( product ) . serviceName ) . toEqual ( 'serviceB' ) ;
274
+ expect ( getFederationMetadata ( product . getFields ( ) [ 'price' ] ) . serviceName ) . toEqual (
274
275
'serviceC' ,
275
276
) ;
276
277
} ) ;
@@ -353,10 +354,10 @@ describe('composeServices', () => {
353
354
name: String!
354
355
}
355
356
` ) ;
356
- expect ( product . getFields ( ) [ 'sku' ] . federation . serviceName ) . toEqual (
357
+ expect ( getFederationMetadata ( product . getFields ( ) [ 'sku' ] ) . serviceName ) . toEqual (
357
358
'serviceB' ,
358
359
) ;
359
- expect ( product . getFields ( ) [ 'name' ] . federation . serviceName ) . toEqual (
360
+ expect ( getFederationMetadata ( product . getFields ( ) [ 'name' ] ) . serviceName ) . toEqual (
360
361
'serviceB' ,
361
362
) ;
362
363
} ) ;
@@ -398,7 +399,7 @@ describe('composeServices', () => {
398
399
name: String!
399
400
}
400
401
` ) ;
401
- expect ( product . getFields ( ) [ 'name' ] . federation . serviceName ) . toEqual (
402
+ expect ( getFederationMetadata ( product . getFields ( ) [ 'name' ] ) . serviceName ) . toEqual (
402
403
'serviceB' ,
403
404
) ;
404
405
} ) ;
@@ -445,7 +446,7 @@ describe('composeServices', () => {
445
446
name: String!
446
447
}
447
448
` ) ;
448
- expect ( product . getFields ( ) [ 'name' ] . federation . serviceName ) . toEqual (
449
+ expect ( getFederationMetadata ( product . getFields ( ) [ 'name' ] ) . serviceName ) . toEqual (
449
450
'serviceB' ,
450
451
) ;
451
452
} ) ;
@@ -595,8 +596,8 @@ describe('composeServices', () => {
595
596
596
597
const product = schema . getType ( 'Product' ) as GraphQLObjectType ;
597
598
598
- expect ( product . federation . serviceName ) . toEqual ( 'serviceA' ) ;
599
- expect ( product . getFields ( ) [ 'id' ] . federation . serviceName ) . toEqual (
599
+ expect ( getFederationMetadata ( product ) . serviceName ) . toEqual ( 'serviceA' ) ;
600
+ expect ( getFederationMetadata ( product . getFields ( ) [ 'id' ] ) . serviceName ) . toEqual (
600
601
'serviceB' ,
601
602
) ;
602
603
} ) ;
@@ -635,7 +636,7 @@ describe('composeServices', () => {
635
636
636
637
const query = schema . getQueryType ( ) ;
637
638
638
- expect ( query . federation . serviceName ) . toBeUndefined ( ) ;
639
+ expect ( getFederationMetadata ( query ) . serviceName ) . toBeUndefined ( ) ;
639
640
} ) ;
640
641
641
642
it ( 'treats root Query type definition as an extension, not base definitions' , ( ) => {
@@ -676,7 +677,7 @@ describe('composeServices', () => {
676
677
677
678
const query = schema . getType ( 'Query' ) as GraphQLObjectType ;
678
679
679
- expect ( query . federation . serviceName ) . toBeUndefined ( ) ;
680
+ expect ( getFederationMetadata ( query ) . serviceName ) . toBeUndefined ( ) ;
680
681
} ) ;
681
682
682
683
it ( 'allows extension of the Mutation type with no base type definition' , ( ) => {
@@ -806,7 +807,7 @@ describe('composeServices', () => {
806
807
807
808
const product = schema . getType ( 'Product' ) ;
808
809
809
- expect ( product . federation . externals ) . toMatchInlineSnapshot ( `
810
+ expect ( getFederationMetadata ( product ) . externals ) . toMatchInlineSnapshot ( `
810
811
Object {
811
812
"serviceB--MISSING": Array [
812
813
Object {
@@ -864,10 +865,10 @@ describe('composeServices', () => {
864
865
price: Int!
865
866
}
866
867
` ) ;
867
- expect ( product . getFields ( ) [ 'price' ] . federation . serviceName ) . toEqual (
868
+ expect ( getFederationMetadata ( product . getFields ( ) [ 'price' ] ) . serviceName ) . toEqual (
868
869
'serviceB' ,
869
870
) ;
870
- expect ( product . federation . serviceName ) . toEqual ( 'serviceA' ) ;
871
+ expect ( getFederationMetadata ( product ) . serviceName ) . toEqual ( 'serviceA' ) ;
871
872
} ) ;
872
873
} ) ;
873
874
@@ -897,7 +898,7 @@ describe('composeServices', () => {
897
898
898
899
const product = schema . getType ( 'Product' ) as GraphQLObjectType ;
899
900
expect (
900
- product . getFields ( ) [ 'price' ] . federation . requires ,
901
+ getFederationMetadata ( product . getFields ( ) [ 'price' ] ) . requires ,
901
902
) . toMatchInlineSnapshot ( `sku` ) ;
902
903
} ) ;
903
904
@@ -930,7 +931,7 @@ describe('composeServices', () => {
930
931
expect ( errors ) . toHaveLength ( 0 ) ;
931
932
932
933
const product = schema . getType ( 'Product' ) as GraphQLObjectType ;
933
- expect ( product . getFields ( ) [ 'price' ] . federation . requires )
934
+ expect ( getFederationMetadata ( product . getFields ( ) [ 'price' ] ) . requires )
934
935
. toMatchInlineSnapshot ( `
935
936
sku {
936
937
id
@@ -970,7 +971,7 @@ describe('composeServices', () => {
970
971
expect ( errors ) . toHaveLength ( 0 ) ;
971
972
972
973
const review = schema . getType ( 'Review' ) as GraphQLObjectType ;
973
- expect ( review . getFields ( ) [ 'product' ] . federation ) . toMatchInlineSnapshot ( `
974
+ expect ( getFederationMetadata ( review . getFields ( ) [ 'product' ] ) ) . toMatchInlineSnapshot ( `
974
975
Object {
975
976
"belongsToValueType": false,
976
977
"provides": sku,
@@ -1013,7 +1014,7 @@ describe('composeServices', () => {
1013
1014
expect ( errors ) . toHaveLength ( 0 ) ;
1014
1015
1015
1016
const review = schema . getType ( 'Review' ) as GraphQLObjectType ;
1016
- expect ( review . getFields ( ) [ 'product' ] . federation . provides )
1017
+ expect ( getFederationMetadata ( review . getFields ( ) [ 'product' ] ) . provides )
1017
1018
. toMatchInlineSnapshot ( `
1018
1019
sku {
1019
1020
id
@@ -1050,7 +1051,7 @@ describe('composeServices', () => {
1050
1051
expect ( errors ) . toHaveLength ( 0 ) ;
1051
1052
1052
1053
const review = schema . getType ( 'Review' ) as GraphQLObjectType ;
1053
- expect ( review . getFields ( ) [ 'products' ] . federation )
1054
+ expect ( getFederationMetadata ( review . getFields ( ) [ 'products' ] ) )
1054
1055
. toMatchInlineSnapshot ( `
1055
1056
Object {
1056
1057
"belongsToValueType": false,
@@ -1099,9 +1100,9 @@ describe('composeServices', () => {
1099
1100
expect ( errors ) . toHaveLength ( 0 ) ;
1100
1101
1101
1102
const valueType = schema . getType ( 'ValueType' ) as GraphQLObjectType ;
1102
- const userField = valueType . getFields ( ) [ 'user' ] . federation ;
1103
- expect ( userField . belongsToValueType ) . toBe ( true ) ;
1104
- expect ( userField . serviceName ) . toBe ( null ) ;
1103
+ const userFieldFederationMetadata = getFederationMetadata ( valueType . getFields ( ) [ 'user' ] ) ;
1104
+ expect ( userFieldFederationMetadata . belongsToValueType ) . toBe ( true ) ;
1105
+ expect ( userFieldFederationMetadata . serviceName ) . toBe ( null ) ;
1105
1106
} ) ;
1106
1107
} ) ;
1107
1108
@@ -1131,7 +1132,7 @@ describe('composeServices', () => {
1131
1132
expect ( errors ) . toHaveLength ( 0 ) ;
1132
1133
1133
1134
const product = schema . getType ( 'Product' ) as GraphQLObjectType ;
1134
- expect ( product . federation . keys ) . toMatchInlineSnapshot ( `
1135
+ expect ( getFederationMetadata ( product ) . keys ) . toMatchInlineSnapshot ( `
1135
1136
Object {
1136
1137
"serviceA": Array [
1137
1138
sku,
@@ -1172,7 +1173,7 @@ describe('composeServices', () => {
1172
1173
expect ( errors ) . toHaveLength ( 0 ) ;
1173
1174
1174
1175
const product = schema . getType ( 'Product' ) as GraphQLObjectType ;
1175
- expect ( product . federation . keys ) . toMatchInlineSnapshot ( `
1176
+ expect ( getFederationMetadata ( product ) . keys ) . toMatchInlineSnapshot ( `
1176
1177
Object {
1177
1178
"serviceA": Array [
1178
1179
color {
@@ -1215,7 +1216,7 @@ describe('composeServices', () => {
1215
1216
expect ( errors ) . toHaveLength ( 0 ) ;
1216
1217
1217
1218
const product = schema . getType ( 'Product' ) as GraphQLObjectType ;
1218
- expect ( product . federation . keys ) . toMatchInlineSnapshot ( `
1219
+ expect ( getFederationMetadata ( product ) . keys ) . toMatchInlineSnapshot ( `
1219
1220
Object {
1220
1221
"serviceA": Array [
1221
1222
color {
0 commit comments