@auto-engineer/narrative 1.128.2 → 1.130.0
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/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-test.log +5 -5
- package/.turbo/turbo-type-check.log +1 -1
- package/CHANGELOG.md +78 -0
- package/dist/src/loader/ts-utils.d.ts.map +1 -1
- package/dist/src/loader/ts-utils.js +11 -0
- package/dist/src/loader/ts-utils.js.map +1 -1
- package/dist/src/parse-graphql-request.d.ts.map +1 -1
- package/dist/src/parse-graphql-request.js +5 -4
- package/dist/src/parse-graphql-request.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/ketchup-plan.md +3 -5
- package/package.json +4 -4
- package/src/getNarratives.specs.ts +509 -1
- package/src/loader/ts-utils.specs.ts +93 -1
- package/src/loader/ts-utils.ts +8 -0
- package/src/parse-graphql-request.specs.ts +33 -0
- package/src/parse-graphql-request.ts +6 -5
|
@@ -28,6 +28,39 @@ describe('parseGraphQlRequest', () => {
|
|
|
28
28
|
args: [{ name: 'input', tsType: 'SubmitAnswerInput', graphqlType: 'SubmitAnswerInput', nullable: false }],
|
|
29
29
|
});
|
|
30
30
|
});
|
|
31
|
+
|
|
32
|
+
it('parses a nullable list of non-null scalars [String!]', () => {
|
|
33
|
+
const request = `mutation AddPlace($amenities: [String!]) {
|
|
34
|
+
addPlace(amenities: $amenities) { id }
|
|
35
|
+
}`;
|
|
36
|
+
|
|
37
|
+
expect(parseGraphQlRequest(request)).toEqual({
|
|
38
|
+
operationName: 'addPlace',
|
|
39
|
+
args: [{ name: 'amenities', tsType: 'string[]', graphqlType: 'String', nullable: true }],
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('parses a non-null list of non-null scalars [String!]!', () => {
|
|
44
|
+
const request = `mutation AddPlace($amenities: [String!]!) {
|
|
45
|
+
addPlace(amenities: $amenities) { id }
|
|
46
|
+
}`;
|
|
47
|
+
|
|
48
|
+
expect(parseGraphQlRequest(request)).toEqual({
|
|
49
|
+
operationName: 'addPlace',
|
|
50
|
+
args: [{ name: 'amenities', tsType: 'string[]', graphqlType: 'String', nullable: false }],
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('parses a nullable list of custom types [CustomType]', () => {
|
|
55
|
+
const request = `query GetItems($filters: [CustomType]) {
|
|
56
|
+
items(filters: $filters) { id }
|
|
57
|
+
}`;
|
|
58
|
+
|
|
59
|
+
expect(parseGraphQlRequest(request)).toEqual({
|
|
60
|
+
operationName: 'items',
|
|
61
|
+
args: [{ name: 'filters', tsType: 'CustomType[]', graphqlType: 'CustomType', nullable: true }],
|
|
62
|
+
});
|
|
63
|
+
});
|
|
31
64
|
});
|
|
32
65
|
|
|
33
66
|
describe('parseSliceRequest', () => {
|
|
@@ -12,14 +12,15 @@ export interface ParsedGraphQlOperation {
|
|
|
12
12
|
args: ParsedArg[];
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
function getTypeName(typeNode: TypeNode): { graphqlType: string; nullable: boolean } {
|
|
15
|
+
function getTypeName(typeNode: TypeNode): { graphqlType: string; nullable: boolean; isArray: boolean } {
|
|
16
16
|
if (typeNode.kind === 'NamedType') {
|
|
17
|
-
return { graphqlType: typeNode.name.value, nullable: true };
|
|
17
|
+
return { graphqlType: typeNode.name.value, nullable: true, isArray: false };
|
|
18
18
|
} else if (typeNode.kind === 'NonNullType') {
|
|
19
19
|
const inner = getTypeName(typeNode.type);
|
|
20
20
|
return { ...inner, nullable: false };
|
|
21
21
|
} else {
|
|
22
|
-
|
|
22
|
+
const inner = getTypeName(typeNode.type);
|
|
23
|
+
return { graphqlType: inner.graphqlType, nullable: true, isArray: true };
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
|
|
@@ -70,11 +71,11 @@ export function parseGraphQlRequest(request: string): ParsedGraphQlOperation {
|
|
|
70
71
|
|
|
71
72
|
const args: ParsedArg[] = (op.variableDefinitions ?? []).map((def) => {
|
|
72
73
|
const varName = def.variable.name.value;
|
|
73
|
-
const { graphqlType, nullable } = getTypeName(def.type);
|
|
74
|
+
const { graphqlType, nullable, isArray } = getTypeName(def.type);
|
|
74
75
|
return {
|
|
75
76
|
name: varName,
|
|
76
77
|
graphqlType,
|
|
77
|
-
tsType: graphqlToTs(graphqlType),
|
|
78
|
+
tsType: isArray ? `${graphqlToTs(graphqlType)}[]` : graphqlToTs(graphqlType),
|
|
78
79
|
nullable,
|
|
79
80
|
};
|
|
80
81
|
});
|