@@ -4,71 +4,39 @@ import AddSelectionSets from './transforms/AddSelectionSets';
44import ExpandAbstractTypes from './transforms/ExpandAbstractTypes' ;
55import WrapConcreteTypes from './transforms/WrapConcreteTypes' ;
66import FilterToSchema from './transforms/FilterToSchema' ;
7- import AddFragmentsByField from './transforms/AddFragmentsByField' ;
87import AddTypenameToAbstract from './transforms/AddTypenameToAbstract' ;
98import CheckResultAndHandleErrors from './transforms/CheckResultAndHandleErrors' ;
109import AddArgumentsAsVariables from './transforms/AddArgumentsAsVariables' ;
1110
1211export function defaultDelegationBinding ( delegationContext : DelegationContext ) : Array < Transform > {
13- const {
14- subschema : schemaOrSubschemaConfig ,
15- targetSchema,
16- fieldName,
17- args,
18- context,
19- info,
20- returnType,
21- transforms = [ ] ,
22- skipTypeMerging,
23- } = delegationContext ;
24- const stitchingInfo : StitchingInfo = info ?. schema . extensions ?. stitchingInfo ;
12+ let delegationTransforms : Array < Transform > = [ new CheckResultAndHandleErrors ( ) ] ;
2513
26- let transformedSchema = stitchingInfo ?. transformedSchemas . get ( schemaOrSubschemaConfig ) ;
27- if ( transformedSchema != null ) {
28- delegationContext . transformedSchema = transformedSchema ;
29- } else {
30- transformedSchema = delegationContext . transformedSchema ;
31- }
32-
33- let delegationTransforms : Array < Transform > = [
34- new CheckResultAndHandleErrors ( info , fieldName , schemaOrSubschemaConfig , context , returnType , skipTypeMerging ) ,
35- ] ;
14+ const info = delegationContext . info ;
15+ const stitchingInfo : StitchingInfo = info ?. schema . extensions ?. stitchingInfo ;
3616
3717 if ( stitchingInfo != null ) {
3818 delegationTransforms = delegationTransforms . concat ( [
39- new AddSelectionSets (
40- info . schema ,
41- returnType ,
42- { } ,
43- stitchingInfo . selectionSetsByField ,
44- stitchingInfo . dynamicSelectionSetsByField
45- ) ,
46- new WrapConcreteTypes ( returnType , transformedSchema ) ,
47- new ExpandAbstractTypes ( info . schema , transformedSchema ) ,
19+ new AddSelectionSets ( { } , stitchingInfo . selectionSetsByField , stitchingInfo . dynamicSelectionSetsByField ) ,
20+ new WrapConcreteTypes ( ) ,
21+ new ExpandAbstractTypes ( ) ,
4822 ] ) ;
4923 } else if ( info != null ) {
50- delegationTransforms = delegationTransforms . concat ( [
51- new WrapConcreteTypes ( returnType , transformedSchema ) ,
52- new ExpandAbstractTypes ( info . schema , transformedSchema ) ,
53- ] ) ;
24+ delegationTransforms = delegationTransforms . concat ( [ new WrapConcreteTypes ( ) , new ExpandAbstractTypes ( ) ] ) ;
5425 } else {
55- delegationTransforms . push ( new WrapConcreteTypes ( returnType , transformedSchema ) ) ;
26+ delegationTransforms . push ( new WrapConcreteTypes ( ) ) ;
5627 }
5728
58- delegationTransforms = delegationTransforms . concat ( transforms . slice ( ) . reverse ( ) ) ;
59-
60- if ( stitchingInfo != null ) {
61- delegationTransforms . push ( new AddFragmentsByField ( targetSchema , stitchingInfo . fragmentsByField ) ) ;
29+ const transforms = delegationContext . transforms ;
30+ if ( transforms != null ) {
31+ delegationTransforms = delegationTransforms . concat ( transforms . slice ( ) . reverse ( ) ) ;
6232 }
6333
34+ const args = delegationContext . args ;
6435 if ( args != null ) {
65- delegationTransforms . push ( new AddArgumentsAsVariables ( targetSchema , args ) ) ;
36+ delegationTransforms . push ( new AddArgumentsAsVariables ( args ) ) ;
6637 }
6738
68- delegationTransforms = delegationTransforms . concat ( [
69- new FilterToSchema ( targetSchema ) ,
70- new AddTypenameToAbstract ( targetSchema ) ,
71- ] ) ;
39+ delegationTransforms = delegationTransforms . concat ( [ new FilterToSchema ( ) , new AddTypenameToAbstract ( ) ] ) ;
7240
7341 return delegationTransforms ;
7442}
0 commit comments