@graphql-tools/delegate 12.0.2 → 12.0.3-alpha-5b28bd1c74cecaeb5ba91bb4b2bf42f00aa84ff5
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/CHANGELOG.md +59 -0
- package/dist/index.cjs +11 -5
- package/dist/index.js +11 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,64 @@
|
|
|
1
1
|
# @graphql-tools/delegate
|
|
2
2
|
|
|
3
|
+
## 12.0.3-alpha-5b28bd1c74cecaeb5ba91bb4b2bf42f00aa84ff5
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
- [#1835](https://github.com/graphql-hive/gateway/pull/1835) [`0028015`](https://github.com/graphql-hive/gateway/commit/00280152c16b87d5e9e83a122ce3477b4f9f5b66) Thanks [@ardatan](https://github.com/ardatan)! - Delegate variable values correctly;
|
|
9
|
+
|
|
10
|
+
When delegating requests with variables that include nested arrays, ensure that null values are preserved and passed correctly to the subschema. This fix addresses issues where null values in nested arrays were not handled properly during delegation.
|
|
11
|
+
|
|
12
|
+
Let's say we have the following schema;
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
makeExecutableSchema({
|
|
16
|
+
typeDefs: /* GraphQL */ `
|
|
17
|
+
type Query {
|
|
18
|
+
test(input: InputType!): [String!]
|
|
19
|
+
}
|
|
20
|
+
input InputType {
|
|
21
|
+
value: [String!]
|
|
22
|
+
}
|
|
23
|
+
`,
|
|
24
|
+
resolvers: {
|
|
25
|
+
Query: {
|
|
26
|
+
test: (_, args) => {
|
|
27
|
+
// Returns the incoming variable value
|
|
28
|
+
return args.input.value;
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
When delegating a query with a variable like:
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"query": "query Test($value: [String!]) { test(input: { value: $value } ) }",
|
|
40
|
+
"variables": { "value": null }
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
And the result was
|
|
45
|
+
```json
|
|
46
|
+
{
|
|
47
|
+
"data": {
|
|
48
|
+
"test": []
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
But with this fix, the result will correctly be:
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"data": {
|
|
57
|
+
"test": null
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
3
62
|
## 12.0.2
|
|
4
63
|
### Patch Changes
|
|
5
64
|
|
package/dist/index.cjs
CHANGED
|
@@ -1806,10 +1806,10 @@ function createRequest({
|
|
|
1806
1806
|
},
|
|
1807
1807
|
type: argAst.type
|
|
1808
1808
|
});
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1809
|
+
const varValue = projectArgumentValue(argValue, argInstance.type);
|
|
1810
|
+
if (varValue != null) {
|
|
1811
|
+
newVariables[varName] = varValue;
|
|
1812
|
+
}
|
|
1813
1813
|
argNodes.push({
|
|
1814
1814
|
kind: graphql.Kind.ARGUMENT,
|
|
1815
1815
|
name: {
|
|
@@ -1883,6 +1883,9 @@ function createRequest({
|
|
|
1883
1883
|
};
|
|
1884
1884
|
}
|
|
1885
1885
|
function projectArgumentValue(argValue, argType) {
|
|
1886
|
+
if (argValue == null) {
|
|
1887
|
+
return argValue;
|
|
1888
|
+
}
|
|
1886
1889
|
if (graphql.isNonNullType(argType)) {
|
|
1887
1890
|
return projectArgumentValue(argValue, argType.ofType);
|
|
1888
1891
|
}
|
|
@@ -1897,7 +1900,10 @@ function projectArgumentValue(argValue, argType) {
|
|
|
1897
1900
|
for (const key in argValue) {
|
|
1898
1901
|
const field = fields[key];
|
|
1899
1902
|
if (field) {
|
|
1900
|
-
|
|
1903
|
+
const varValue = projectArgumentValue(argValue[key], field.type);
|
|
1904
|
+
if (varValue != null) {
|
|
1905
|
+
projectedValue[key] = varValue;
|
|
1906
|
+
}
|
|
1901
1907
|
}
|
|
1902
1908
|
}
|
|
1903
1909
|
return projectedValue;
|
package/dist/index.js
CHANGED
|
@@ -1806,10 +1806,10 @@ function createRequest({
|
|
|
1806
1806
|
},
|
|
1807
1807
|
type: argAst.type
|
|
1808
1808
|
});
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1809
|
+
const varValue = projectArgumentValue(argValue, argInstance.type);
|
|
1810
|
+
if (varValue != null) {
|
|
1811
|
+
newVariables[varName] = varValue;
|
|
1812
|
+
}
|
|
1813
1813
|
argNodes.push({
|
|
1814
1814
|
kind: Kind.ARGUMENT,
|
|
1815
1815
|
name: {
|
|
@@ -1883,6 +1883,9 @@ function createRequest({
|
|
|
1883
1883
|
};
|
|
1884
1884
|
}
|
|
1885
1885
|
function projectArgumentValue(argValue, argType) {
|
|
1886
|
+
if (argValue == null) {
|
|
1887
|
+
return argValue;
|
|
1888
|
+
}
|
|
1886
1889
|
if (isNonNullType(argType)) {
|
|
1887
1890
|
return projectArgumentValue(argValue, argType.ofType);
|
|
1888
1891
|
}
|
|
@@ -1897,7 +1900,10 @@ function projectArgumentValue(argValue, argType) {
|
|
|
1897
1900
|
for (const key in argValue) {
|
|
1898
1901
|
const field = fields[key];
|
|
1899
1902
|
if (field) {
|
|
1900
|
-
|
|
1903
|
+
const varValue = projectArgumentValue(argValue[key], field.type);
|
|
1904
|
+
if (varValue != null) {
|
|
1905
|
+
projectedValue[key] = varValue;
|
|
1906
|
+
}
|
|
1901
1907
|
}
|
|
1902
1908
|
}
|
|
1903
1909
|
return projectedValue;
|
package/package.json
CHANGED