@khanacademy/graphql-flow 3.1.1 → 3.1.2
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
CHANGED
|
@@ -27,7 +27,7 @@ const inputObjectToFlow = (ctx, name) => {
|
|
|
27
27
|
return babelTypes.tsLiteralType(babelTypes.stringLiteral(`Unknown input object ${name}`));
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
return (0, _utils.maybeAddDescriptionComment)(inputObject.description, (0, _utils.objectTypeFromProperties)(inputObject.inputFields.map(vbl => (0, _utils.maybeAddDescriptionComment)(vbl.description, maybeOptionalObjectTypeProperty(vbl.name, inputRefToFlow(ctx, vbl.type))))));
|
|
30
|
+
return (0, _utils.maybeAddDescriptionComment)(inputObject.description, (0, _utils.objectTypeFromProperties)(inputObject.inputFields.map(vbl => (0, _utils.maybeAddDescriptionComment)(vbl.description, maybeOptionalObjectTypeProperty(vbl.name, inputRefToFlow(ctx, vbl.type, vbl.defaultValue != null))))));
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
exports.inputObjectToFlow = inputObjectToFlow;
|
|
@@ -44,9 +44,11 @@ const maybeOptionalObjectTypeProperty = (name, type) => {
|
|
|
44
44
|
|
|
45
45
|
exports.maybeOptionalObjectTypeProperty = maybeOptionalObjectTypeProperty;
|
|
46
46
|
|
|
47
|
-
const inputRefToFlow = (ctx, inputRef) => {
|
|
47
|
+
const inputRefToFlow = (ctx, inputRef, hasDefaultValue = false) => {
|
|
48
48
|
if (inputRef.kind === "NON_NULL") {
|
|
49
|
-
|
|
49
|
+
const result = _inputRefToFlow(ctx, inputRef.ofType);
|
|
50
|
+
|
|
51
|
+
return hasDefaultValue ? (0, _utils.nullableType)(result) : result;
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
const result = _inputRefToFlow(ctx, inputRef);
|
package/package.json
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/graphql-flow",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"bin": {
|
|
5
5
|
"graphql-flow": "./dist/cli/run.js"
|
|
6
6
|
},
|
|
7
|
+
"jest": {
|
|
8
|
+
"testPathIgnorePatterns": [
|
|
9
|
+
"dist"
|
|
10
|
+
]
|
|
11
|
+
},
|
|
7
12
|
"scripts": {
|
|
8
13
|
"test": "jest",
|
|
9
14
|
"publish:ci": "yarn run build && changeset publish",
|
|
@@ -31,7 +31,7 @@ export const inputObjectToFlow = (
|
|
|
31
31
|
vbl.description,
|
|
32
32
|
maybeOptionalObjectTypeProperty(
|
|
33
33
|
vbl.name,
|
|
34
|
-
inputRefToFlow(ctx, vbl.type),
|
|
34
|
+
inputRefToFlow(ctx, vbl.type, vbl.defaultValue != null),
|
|
35
35
|
),
|
|
36
36
|
),
|
|
37
37
|
),
|
|
@@ -58,9 +58,11 @@ export const maybeOptionalObjectTypeProperty = (
|
|
|
58
58
|
export const inputRefToFlow = (
|
|
59
59
|
ctx: Context,
|
|
60
60
|
inputRef: IntrospectionInputTypeRef,
|
|
61
|
+
hasDefaultValue = false,
|
|
61
62
|
): babelTypes.TSType => {
|
|
62
63
|
if (inputRef.kind === "NON_NULL") {
|
|
63
|
-
|
|
64
|
+
const result = _inputRefToFlow(ctx, inputRef.ofType);
|
|
65
|
+
return hasDefaultValue ? nullableType(result) : result;
|
|
64
66
|
}
|
|
65
67
|
const result = _inputRefToFlow(ctx, inputRef);
|
|
66
68
|
return transferLeadingComments(result, nullableType(result));
|