@apollo/gateway 2.4.2 → 2.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apollo/gateway",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.3",
|
|
4
4
|
"description": "Apollo Gateway",
|
|
5
5
|
"author": "Apollo <packages@apollographql.com>",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@apollo/composition": "2.4.
|
|
29
|
-
"@apollo/federation-internals": "2.4.
|
|
30
|
-
"@apollo/query-planner": "2.4.
|
|
28
|
+
"@apollo/composition": "2.4.3",
|
|
29
|
+
"@apollo/federation-internals": "2.4.3",
|
|
30
|
+
"@apollo/query-planner": "2.4.3",
|
|
31
31
|
"@apollo/server-gateway-interface": "^1.1.0",
|
|
32
32
|
"@apollo/usage-reporting-protobuf": "^4.1.0",
|
|
33
33
|
"@apollo/utils.createhash": "^2.0.0",
|
|
@@ -3802,10 +3802,15 @@ describe('executeQueryPlan', () => {
|
|
|
3802
3802
|
s1,
|
|
3803
3803
|
}: {
|
|
3804
3804
|
s1?: {
|
|
3805
|
+
// additional resolvers for interface I
|
|
3805
3806
|
iResolversExtra?: any,
|
|
3807
|
+
// provide a default __resolveReference for the interface
|
|
3806
3808
|
hasIResolveReference?: boolean,
|
|
3809
|
+
// turn an id into extra data returned by __resolveReference (if hasIResolveReference is true)
|
|
3807
3810
|
iResolveReferenceExtra?: (id: string) => { [k: string]: any },
|
|
3811
|
+
// additional resolvers for type A
|
|
3808
3812
|
aResolversExtra?: any,
|
|
3813
|
+
// additional resolvers for type B
|
|
3809
3814
|
bResolversExtra?: any,
|
|
3810
3815
|
}
|
|
3811
3816
|
}) => {
|
|
@@ -4136,7 +4141,75 @@ describe('executeQueryPlan', () => {
|
|
|
4136
4141
|
+ 'Either the object returned by "I.__resolveReference" must include a valid `__typename` field, '
|
|
4137
4142
|
+ 'or the "I" type should provide a "resolveType" function or each possible type should provide an "isTypeOf" function.'
|
|
4138
4143
|
],
|
|
4139
|
-
}
|
|
4144
|
+
}, {
|
|
4145
|
+
name: 'with an async __resolveReference and a non-default __resolveType',
|
|
4146
|
+
s1: {
|
|
4147
|
+
iResolversExtra: {
|
|
4148
|
+
async __resolveReference(ref: { id: string }) {
|
|
4149
|
+
return ref.id === 'idA'
|
|
4150
|
+
? { id: ref.id, x: 1, z: 3 }
|
|
4151
|
+
: { id: ref.id, x: 10, w: 30 };
|
|
4152
|
+
},
|
|
4153
|
+
__resolveType(ref: { id: string }) {
|
|
4154
|
+
switch (ref.id) {
|
|
4155
|
+
case 'idA':
|
|
4156
|
+
return 'A';
|
|
4157
|
+
case 'idB':
|
|
4158
|
+
return 'B';
|
|
4159
|
+
default:
|
|
4160
|
+
throw new Error('Unknown type: ' + ref.id);
|
|
4161
|
+
}
|
|
4162
|
+
},
|
|
4163
|
+
},
|
|
4164
|
+
},
|
|
4165
|
+
}, {
|
|
4166
|
+
name: 'with an async __resolveReference and a non-default async __resolveType',
|
|
4167
|
+
s1: {
|
|
4168
|
+
iResolversExtra: {
|
|
4169
|
+
async __resolveReference(ref: { id: string }) {
|
|
4170
|
+
return ref.id === 'idA'
|
|
4171
|
+
? { id: ref.id, x: 1, z: 3 }
|
|
4172
|
+
: { id: ref.id, x: 10, w: 30 };
|
|
4173
|
+
},
|
|
4174
|
+
async __resolveType(ref: { id: string }) {
|
|
4175
|
+
switch (ref.id) {
|
|
4176
|
+
case 'idA':
|
|
4177
|
+
return 'A';
|
|
4178
|
+
case 'idB':
|
|
4179
|
+
return 'B';
|
|
4180
|
+
default:
|
|
4181
|
+
throw new Error('Unknown type: ' + ref.id);
|
|
4182
|
+
}
|
|
4183
|
+
},
|
|
4184
|
+
},
|
|
4185
|
+
},
|
|
4186
|
+
}, {
|
|
4187
|
+
name: 'with an async __resolveReference and async __isTypeOf on implementations',
|
|
4188
|
+
s1: {
|
|
4189
|
+
iResolversExtra: {
|
|
4190
|
+
async __resolveReference(ref: {
|
|
4191
|
+
id: string;
|
|
4192
|
+
// I don't understand the TypeScript error that occurs when the
|
|
4193
|
+
// return type is removed here (like all the others); it surfaces
|
|
4194
|
+
// because `aResolversExtra` is defined, which I can't explain.
|
|
4195
|
+
}): Promise<Record<string, any>> {
|
|
4196
|
+
return ref.id === 'idA'
|
|
4197
|
+
? { id: ref.id, x: 1, z: 3 }
|
|
4198
|
+
: { id: ref.id, x: 10, w: 30 };
|
|
4199
|
+
},
|
|
4200
|
+
},
|
|
4201
|
+
aResolversExtra: {
|
|
4202
|
+
async __isTypeOf(ref: { id: string }) {
|
|
4203
|
+
return ref.id === 'idA';
|
|
4204
|
+
},
|
|
4205
|
+
},
|
|
4206
|
+
bResolversExtra: {
|
|
4207
|
+
async __isTypeOf(ref: { id: string }) {
|
|
4208
|
+
return ref.id === 'idB';
|
|
4209
|
+
},
|
|
4210
|
+
},
|
|
4211
|
+
},
|
|
4212
|
+
}])('resolving an interface @key $name', async ({ s1, expectedErrors }) => {
|
|
4140
4213
|
const tester = defineSchema({ s1 });
|
|
4141
4214
|
|
|
4142
4215
|
const { plan, response } = await tester(`
|