@newmo/graphql-fake-core 0.6.0 → 0.8.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/README.md +11 -73
- package/dist/esm/code-generator.d.ts.map +1 -1
- package/dist/esm/code-generator.js +40 -0
- package/dist/esm/code-generator.js.map +1 -1
- package/dist/esm/createMock.d.ts +2 -0
- package/dist/esm/createMock.d.ts.map +1 -1
- package/dist/esm/createMock.js +1 -0
- package/dist/esm/createMock.js.map +1 -1
- package/dist/esm/extend-schema.d.ts +1 -1
- package/dist/esm/extend-schema.d.ts.map +1 -1
- package/dist/esm/extend-schema.js +57 -0
- package/dist/esm/extend-schema.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/schema-scanner.d.ts +9 -3
- package/dist/esm/schema-scanner.d.ts.map +1 -1
- package/dist/esm/schema-scanner.js +111 -19
- package/dist/esm/schema-scanner.js.map +1 -1
- package/package.json +2 -2
- package/src/code-generator.ts +52 -1
- package/src/createMock.ts +3 -1
- package/src/extend-schema.ts +57 -0
- package/src/index.ts +1 -1
- package/src/schema-scanner.ts +138 -26
package/README.md
CHANGED
|
@@ -1,83 +1,22 @@
|
|
|
1
|
-
# @newmo/graphql-fake-
|
|
1
|
+
# @newmo/graphql-fake-core
|
|
2
2
|
|
|
3
|
-
GraphQL Fake
|
|
3
|
+
GraphQL Fake Core Library.
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
- Static Path
|
|
8
|
-
- Support Declarative Fake via `@example` directive.
|
|
9
|
-
- [ ] Dynamic Path
|
|
10
|
-
- Support Framework-Agnostic Fake for testing via HTTP
|
|
11
|
-
|
|
12
|
-
## Installation
|
|
13
|
-
|
|
14
|
-
1. Add `@exampleID`, `@exampleString`, `@exampleInt`, `@exampleFloat`, `@exampleBoolean` directive to your schema.
|
|
5
|
+
## Usage
|
|
15
6
|
|
|
16
|
-
|
|
17
|
-
"""
|
|
18
|
-
@exampleID directive specifies an example value for a ID field.
|
|
19
|
-
This example value is used in the fake data.
|
|
20
|
-
ID value will be unique between all ID fake data.
|
|
21
|
-
"""
|
|
22
|
-
directive @exampleID(
|
|
23
|
-
"""
|
|
24
|
-
The value of the ID field.
|
|
25
|
-
@exampleID(value: "id")
|
|
26
|
-
"""
|
|
27
|
-
value: ID!
|
|
28
|
-
) on FIELD_DEFINITION
|
|
29
|
-
"""
|
|
30
|
-
@exampleString directive specifies an example value for a String field.
|
|
31
|
-
This example value is used in the fake data.
|
|
32
|
-
"""
|
|
33
|
-
directive @exampleString(
|
|
34
|
-
"""
|
|
35
|
-
The value of the String field.
|
|
36
|
-
@exampleString(value: "example")
|
|
37
|
-
"""
|
|
38
|
-
value: String!
|
|
39
|
-
) on FIELD_DEFINITION
|
|
40
|
-
"""
|
|
41
|
-
@exampleInt directive specifies an example value for a Inf field.
|
|
42
|
-
This example value is used in the fake data.
|
|
43
|
-
"""
|
|
44
|
-
directive @exampleInt(
|
|
45
|
-
"""
|
|
46
|
-
The value of the Int field.
|
|
47
|
-
@exampleInt(value: 1)
|
|
48
|
-
"""
|
|
49
|
-
value: Int!
|
|
50
|
-
) on FIELD_DEFINITION
|
|
51
|
-
"""
|
|
52
|
-
@exampleFloat directive specifies an example value for a Float field.
|
|
53
|
-
This example value is used in the fake data.
|
|
54
|
-
"""
|
|
55
|
-
directive @exampleFloat(
|
|
56
|
-
"""
|
|
57
|
-
The value of the Float field.
|
|
58
|
-
@exampleFloat(value: 1.0)
|
|
59
|
-
"""
|
|
60
|
-
value: Float!
|
|
61
|
-
) on FIELD_DEFINITION
|
|
62
|
-
"""
|
|
63
|
-
@exampleBoolean directive specifies an example value for a Boolean field.
|
|
64
|
-
This example value is used in the fake data.
|
|
65
|
-
"""
|
|
66
|
-
directive @exampleBoolean(
|
|
67
|
-
"""
|
|
68
|
-
The value of the Boolean field.
|
|
69
|
-
@exampleBoolean(value: true)
|
|
70
|
-
"""
|
|
71
|
-
value: Boolean!
|
|
72
|
-
) on FIELD_DEFINITION
|
|
73
|
-
```
|
|
7
|
+
See <https://github.com/newmo-oss/graphql-fake-server>
|
|
74
8
|
|
|
75
|
-
##
|
|
9
|
+
## Features
|
|
76
10
|
|
|
11
|
+
- Example directive using `@exampleString` etc...
|
|
12
|
+
- Generate Mock data model from GraphQL Schema
|
|
13
|
+
- Run mock data model and get mock data
|
|
77
14
|
|
|
78
15
|
## Tests
|
|
79
16
|
|
|
80
|
-
|
|
17
|
+
```sh
|
|
18
|
+
npm test
|
|
19
|
+
```
|
|
81
20
|
|
|
82
21
|
## Contributing
|
|
83
22
|
|
|
@@ -94,4 +33,3 @@ MIT
|
|
|
94
33
|
## Credits
|
|
95
34
|
|
|
96
35
|
- [mizdra/graphql-codegen-typescript-fabbrica: GraphQL Code Generator Plugin to define fake data factory.](https://github.com/mizdra/graphql-codegen-typescript-fabbrica)
|
|
97
|
-
- [graphql-kit/graphql-faker: 🎲 Mock or extend your GraphQL API with faked data. No coding required.](https://github.com/graphql-kit/graphql-faker)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-generator.d.ts","sourceRoot":"","sources":["../../src/code-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"code-generator.d.ts","sourceRoot":"","sources":["../../src/code-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAKR,QAAQ,EAEX,MAAM,qBAAqB,CAAC;AAE7B,MAAM,MAAM,gBAAgB,GAAG;IAC3B,UAAU,EAAE,YAAY,GAAG,YAAY,GAAG,UAAU,CAAC;CACxD,GAAG,MAAM,CAAC;AAUX,eAAO,MAAM,yBAAyB,kBAEnC;IACC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAClB,KAAG,MAGH,CAAC;AACF,eAAO,MAAM,2BAA2B,qCAIrC;IACC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAClB,KAAG,MASH,CAAC;AAiIF,wBAAgB,YAAY,CAAC,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,MAAM,CA2BpF"}
|
|
@@ -100,6 +100,42 @@ function __id({ name, key, depth }${isTypescript ? ": { name: string; key: strin
|
|
|
100
100
|
return name + String(depth) + String(count);
|
|
101
101
|
}`;
|
|
102
102
|
}
|
|
103
|
+
// Return first type of union type / interface
|
|
104
|
+
// union Author = User | Admin
|
|
105
|
+
// We can not understand which type should be returned
|
|
106
|
+
// As a result, we always return the first type of the union type/interface
|
|
107
|
+
function generateUnionOrInterfaceTypeCode(config, typeInfo) {
|
|
108
|
+
const { name } = typeInfo;
|
|
109
|
+
const indent = " ";
|
|
110
|
+
const firstTypeNameOfUnionType = typeInfo.possibleTypes[0];
|
|
111
|
+
if (!firstTypeNameOfUnionType) {
|
|
112
|
+
throw new Error(`Union type ${name} has no possible types`);
|
|
113
|
+
}
|
|
114
|
+
// __typename is required for Union type
|
|
115
|
+
// https://stackoverflow.com/questions/59519816/abstract-type-x-must-resolve-to-an-object-type-at-runtime-for-field-query-user
|
|
116
|
+
// https://www.apollographql.com/docs/federation/entities/#2-define-a-reference-resolver
|
|
117
|
+
const functionBodyCode = `
|
|
118
|
+
${indent}return {
|
|
119
|
+
${indent}${indent}__typename: "${firstTypeNameOfUnionType}",
|
|
120
|
+
${indent}${indent}...${generateCreateReferenceCode({
|
|
121
|
+
typeName: firstTypeNameOfUnionType,
|
|
122
|
+
fieldName: typeInfo.name,
|
|
123
|
+
config,
|
|
124
|
+
})}
|
|
125
|
+
};
|
|
126
|
+
`.trim();
|
|
127
|
+
if (config.outputType === "typescript") {
|
|
128
|
+
return `
|
|
129
|
+
export function create${name}({ defaultFields, depth = 0 }: { defaultFields?: Partial<${name}>, depth?: number } = {}): ${name} {
|
|
130
|
+
${functionBodyCode}
|
|
131
|
+
}
|
|
132
|
+
`.trim();
|
|
133
|
+
}
|
|
134
|
+
return `
|
|
135
|
+
function create${name}({ defaultFields, depth = 0 } = {}) {
|
|
136
|
+
${functionBodyCode}
|
|
137
|
+
}`;
|
|
138
|
+
}
|
|
103
139
|
export function generateCode(config, typeInfos) {
|
|
104
140
|
let code = "";
|
|
105
141
|
if (config.outputType === "typescript") {
|
|
@@ -115,6 +151,10 @@ export function generateCode(config, typeInfos) {
|
|
|
115
151
|
}
|
|
116
152
|
}
|
|
117
153
|
for (const typeInfo of typeInfos) {
|
|
154
|
+
if (typeInfo.type === "union" || typeInfo.type === "interface") {
|
|
155
|
+
code += generateUnionOrInterfaceTypeCode(config, typeInfo);
|
|
156
|
+
code += "\n";
|
|
157
|
+
}
|
|
118
158
|
if (typeInfo.type === "object") {
|
|
119
159
|
code += generateFactoryCode(config, typeInfo);
|
|
120
160
|
code += "\n";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-generator.js","sourceRoot":"","sources":["../../src/code-generator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"code-generator.js","sourceRoot":"","sources":["../../src/code-generator.ts"],"names":[],"mappings":"AAaA,MAAM,aAAa,GAAG,CAAC,gBAAkC,EAAU,EAAE;IACjE,IAAI,OAAO,IAAI,gBAAgB,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAClD,CAAC;IACD,IAAI,YAAY,IAAI,gBAAgB,EAAE,CAAC;QACnC,OAAO,gBAAgB,CAAC,UAAU,CAAC;IACvC,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;AACpF,C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AC;YAC7B,IAAI,IAAI,mBAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YAC9C,IAAI,IAAI,IAAI,CAAC;YACb,IAAI,IAAI,mBAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YAC9C,IAAI,IAAI,IAAI,CAAC;QACjB,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC"}
|
package/dist/esm/createMock.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { GraphQLSchema } from "graphql/index.js";
|
|
2
|
+
import { type TypeInfo } from "./schema-scanner.js";
|
|
2
3
|
export type MockObject = Record<string, unknown>;
|
|
3
4
|
export type CreateMockOptions = {
|
|
4
5
|
schema: GraphQLSchema;
|
|
@@ -11,6 +12,7 @@ export type CreateMockResult = {
|
|
|
11
12
|
} | {
|
|
12
13
|
ok: false;
|
|
13
14
|
code: string;
|
|
15
|
+
typeInfos: TypeInfo[];
|
|
14
16
|
error: Error;
|
|
15
17
|
};
|
|
16
18
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMock.d.ts","sourceRoot":"","sources":["../../src/createMock.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"createMock.d.ts","sourceRoot":"","sources":["../../src/createMock.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGtD,OAAO,EAAE,KAAK,QAAQ,EAAgB,MAAM,qBAAqB,CAAC;AAElE,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACjD,MAAM,MAAM,iBAAiB,GAAG;IAC5B,MAAM,EAAE,aAAa,CAAC;IACtB,sBAAsB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/C,CAAC;AAIF,MAAM,MAAM,gBAAgB,GACtB;IACI,EAAE,EAAE,IAAI,CAAC;IACT,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,CAAC;CACpB,GACD;IACI,EAAE,EAAE,KAAK,CAAC;IACV,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,KAAK,EAAE,KAAK,CAAC;CAChB,CAAC;AACR;;;GAGG;AACH,eAAO,MAAM,UAAU,YAAmB,iBAAiB,KAAG,QAAQ,gBAAgB,CA+BrF,CAAC"}
|
package/dist/esm/createMock.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMock.js","sourceRoot":"","sources":["../../src/createMock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,
|
|
1
|
+
{"version":3,"file":"createMock.js","sourceRoot":"","sources":["../../src/createMock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAiB,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAOlE,MAAM,WAAW,GAAG,CAAC,GAAY,EAAE,EAAE;IACjC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;AAC3C,CAAC,CAAC;AAaF;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAAE,OAA0B,EAA6B,EAAE;IACtF,MAAM,gBAAgB,GAAG,eAAe,CAAC;QACrC,sBAAsB,EAAE,OAAO,CAAC,sBAAsB,IAAI,CAAC;KAC9D,CAAC,CAAC;IACH,MAAM,SAAS,GAAG,YAAY,CAAC,gBAAgB,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACjE,MAAM,IAAI,GAAG,YAAY,CACrB;QACI,GAAG,gBAAgB;QACnB,UAAU,EAAE,UAAU;KACzB,EACD,SAAS,CACZ,CAAC;IACF,IAAI,CAAC;QACD,yCAAyC;QACzC,MAAM,OAAO,GAAG,EAAE,CAAC;QACnB,EAAE,CAAC,eAAe,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QACtC,8DAA8D;QAC9D,MAAM,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;QACzC,OAAO;YACH,EAAE,EAAE,IAAI;YACR,IAAI;YACJ,IAAI,EAAE,WAAW;SACpB,CAAC;IACN,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO;YACH,EAAE,EAAE,KAAK;YACT,IAAI;YACJ,SAAS;YACT,KAAK,EAAE,KAAc;SACxB,CAAC;IACN,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const EXAMPLE_DIRECTIVE = "\n\"\"\"\n@exampleID directive specifies an example value for a ID field.\nThis example value is used in the fake data.\nID value will be unique between all ID fake data.\n\"\"\"\ndirective @exampleID(\n \"\"\"\n The value of the ID field.\n @exampleID(value: \"id\")\n \"\"\"\n value: ID!\n) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION\n\"\"\"\n@exampleString directive specifies an example value for a String field.\nThis example value is used in the fake data.\n\"\"\"\ndirective @exampleString(\n \"\"\"\n The value of the String field.\n @exampleString(value: \"example\")\n \"\"\"\n value: String!\n) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION\n\"\"\"\n@exampleInt directive specifies an example value for a Inf field.\nThis example value is used in the fake data.\n\"\"\"\ndirective @exampleInt(\n \"\"\"\n The value of the Int field.\n @exampleInt(value: 1)\n \"\"\"\n value: Int!\n) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION\n\"\"\"\n@exampleFloat directive specifies an example value for a Float field.\nThis example value is used in the fake data.\n\"\"\"\ndirective @exampleFloat(\n \"\"\"\n The value of the Float field.\n @exampleFloat(value: 1.0)\n \"\"\"\n value: Float!\n) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION\n\"\"\"\n@exampleBoolean directive specifies an example value for a Boolean field.\nThis example value is used in the fake data.\n\"\"\"\ndirective @exampleBoolean(\n \"\"\"\n The value of the Boolean field.\n @exampleBoolean(value: true)\n \"\"\"\n value: Boolean!\n) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION\n";
|
|
1
|
+
export declare const EXAMPLE_DIRECTIVE = "\n\"\"\"\n@exampleID directive specifies an example value for a ID field.\nThis example value is used in the fake data.\nID value will be unique between all ID fake data.\n\"\"\"\ndirective @exampleID(\n \"\"\"\n The value of the ID field.\n @exampleID(value: \"id\")\n \"\"\"\n value: ID!\n) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION\n\"\"\"\n@exampleString directive specifies an example value for a String field.\nThis example value is used in the fake data.\n\"\"\"\ndirective @exampleString(\n \"\"\"\n The value of the String field.\n @exampleString(value: \"example\")\n \"\"\"\n value: String!\n) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION\n\"\"\"\n@exampleInt directive specifies an example value for a Inf field.\nThis example value is used in the fake data.\n\"\"\"\ndirective @exampleInt(\n \"\"\"\n The value of the Int field.\n @exampleInt(value: 1)\n \"\"\"\n value: Int!\n) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION\n\"\"\"\n@exampleFloat directive specifies an example value for a Float field.\nThis example value is used in the fake data.\n\"\"\"\ndirective @exampleFloat(\n \"\"\"\n The value of the Float field.\n @exampleFloat(value: 1.0)\n \"\"\"\n value: Float!\n) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION\n\"\"\"\n@exampleBoolean directive specifies an example value for a Boolean field.\nThis example value is used in the fake data.\n\"\"\"\ndirective @exampleBoolean(\n \"\"\"\n The value of the Boolean field.\n @exampleBoolean(value: true)\n \"\"\"\n value: Boolean!\n) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION\n\n\"\"\"\n@exampleArrayID directive specifies an example value for a array of ID field.\nThis example value is used in the fake data.\nID value will be unique between all ID fake data.\n\"\"\"\ndirective @exampleArrayID(\n \"\"\"\n The value of the ID field.\n @exampleArrayID(value: [\"id1\", \"id2\"])\n \"\"\"\n values: [ID!]!\n) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION\n\"\"\"\n@exampleArrayString directive specifies an example value for a array of String field.\nThis example value is used in the fake data.\n\"\"\"\ndirective @exampleArrayString(\n \"\"\"\n The value of the String field.\n @exampleArrayString(value: [\"example1\", \"example2\"])\n \"\"\"\n values: [String!]!\n) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION\n\"\"\"\n@exampleArrayInt directive specifies an example value for a array of Int field.\nThis example value is used in the fake data.\n\"\"\"\ndirective @exampleArrayInt(\n \"\"\"\n The value of the Int field.\n @exampleArrayInt(value: [1, 2])\n \"\"\"\n values: [Int!]!\n) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION\n\"\"\"\n@exampleArrayFloat directive specifies an example value for a array of Float field.\nThis example value is used in the fake data.\n\"\"\"\ndirective @exampleArrayFloat(\n \"\"\"\n The value of the Float field.\n @exampleArrayFloat(value: [1.0, 2.0])\n \"\"\"\n values: [Float!]!\n) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION\n\"\"\"\n@exampleArrayBoolean directive specifies an example value for a array of Boolean field.\nThis example value is used in the fake data.\n\"\"\"\ndirective @exampleArrayBoolean(\n \"\"\"\n The value of the Boolean field.\n @exampleArrayBoolean(value: [true, false])\n \"\"\"\n values: [Boolean!]!\n) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION\n";
|
|
2
2
|
export declare const extendSchema: (schema: string) => string;
|
|
3
3
|
//# sourceMappingURL=extend-schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extend-schema.d.ts","sourceRoot":"","sources":["../../src/extend-schema.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"extend-schema.d.ts","sourceRoot":"","sources":["../../src/extend-schema.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,6lHAkH7B,CAAC;AACF,eAAO,MAAM,YAAY,WAAY,MAAM,WAE1C,CAAC"}
|
|
@@ -55,6 +55,63 @@ directive @exampleBoolean(
|
|
|
55
55
|
"""
|
|
56
56
|
value: Boolean!
|
|
57
57
|
) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION
|
|
58
|
+
|
|
59
|
+
"""
|
|
60
|
+
@exampleArrayID directive specifies an example value for a array of ID field.
|
|
61
|
+
This example value is used in the fake data.
|
|
62
|
+
ID value will be unique between all ID fake data.
|
|
63
|
+
"""
|
|
64
|
+
directive @exampleArrayID(
|
|
65
|
+
"""
|
|
66
|
+
The value of the ID field.
|
|
67
|
+
@exampleArrayID(value: ["id1", "id2"])
|
|
68
|
+
"""
|
|
69
|
+
values: [ID!]!
|
|
70
|
+
) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION
|
|
71
|
+
"""
|
|
72
|
+
@exampleArrayString directive specifies an example value for a array of String field.
|
|
73
|
+
This example value is used in the fake data.
|
|
74
|
+
"""
|
|
75
|
+
directive @exampleArrayString(
|
|
76
|
+
"""
|
|
77
|
+
The value of the String field.
|
|
78
|
+
@exampleArrayString(value: ["example1", "example2"])
|
|
79
|
+
"""
|
|
80
|
+
values: [String!]!
|
|
81
|
+
) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION
|
|
82
|
+
"""
|
|
83
|
+
@exampleArrayInt directive specifies an example value for a array of Int field.
|
|
84
|
+
This example value is used in the fake data.
|
|
85
|
+
"""
|
|
86
|
+
directive @exampleArrayInt(
|
|
87
|
+
"""
|
|
88
|
+
The value of the Int field.
|
|
89
|
+
@exampleArrayInt(value: [1, 2])
|
|
90
|
+
"""
|
|
91
|
+
values: [Int!]!
|
|
92
|
+
) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION
|
|
93
|
+
"""
|
|
94
|
+
@exampleArrayFloat directive specifies an example value for a array of Float field.
|
|
95
|
+
This example value is used in the fake data.
|
|
96
|
+
"""
|
|
97
|
+
directive @exampleArrayFloat(
|
|
98
|
+
"""
|
|
99
|
+
The value of the Float field.
|
|
100
|
+
@exampleArrayFloat(value: [1.0, 2.0])
|
|
101
|
+
"""
|
|
102
|
+
values: [Float!]!
|
|
103
|
+
) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION
|
|
104
|
+
"""
|
|
105
|
+
@exampleArrayBoolean directive specifies an example value for a array of Boolean field.
|
|
106
|
+
This example value is used in the fake data.
|
|
107
|
+
"""
|
|
108
|
+
directive @exampleArrayBoolean(
|
|
109
|
+
"""
|
|
110
|
+
The value of the Boolean field.
|
|
111
|
+
@exampleArrayBoolean(value: [true, false])
|
|
112
|
+
"""
|
|
113
|
+
values: [Boolean!]!
|
|
114
|
+
) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION
|
|
58
115
|
`;
|
|
59
116
|
export const extendSchema = (schema) => {
|
|
60
117
|
return EXAMPLE_DIRECTIVE + schema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extend-schema.js","sourceRoot":"","sources":["../../src/extend-schema.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG
|
|
1
|
+
{"version":3,"file":"extend-schema.js","sourceRoot":"","sources":["../../src/extend-schema.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkHhC,CAAC;AACF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAAc,EAAE,EAAE;IAC3C,OAAO,iBAAiB,GAAG,MAAM,CAAC;AACtC,CAAC,CAAC"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { normalizeConfig, validateConfig } from "./config.js";
|
|
|
4
4
|
export type { Config, RawConfig } from "./config.js";
|
|
5
5
|
export { extendSchema, EXAMPLE_DIRECTIVE } from "./extend-schema.js";
|
|
6
6
|
export { getTypeInfos } from "./schema-scanner.js";
|
|
7
|
-
export type { TypeInfo,
|
|
7
|
+
export type { TypeInfo, InterfaceTypeInfo, ObjectTypeInfo, ExampleDirective, ExampleDirectiveValue, ExampleDirectionExpression, } from "./schema-scanner.js";
|
|
8
8
|
export { createMock } from "./createMock.js";
|
|
9
9
|
export type { CreateMockResult, MockObject, CreateMockOptions } from "./createMock.js";
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC9D,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,YAAY,EACR,QAAQ,EACR,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC9D,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,YAAY,EACR,QAAQ,EACR,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACrB,0BAA0B,GAC7B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -24,14 +24,20 @@ export type EnumTypeInfo = {
|
|
|
24
24
|
name: string;
|
|
25
25
|
fields: FieldInfo[];
|
|
26
26
|
};
|
|
27
|
-
export type
|
|
28
|
-
type: "
|
|
27
|
+
export type InterfaceTypeInfo = {
|
|
28
|
+
type: "interface";
|
|
29
29
|
name: string;
|
|
30
30
|
possibleTypes: string[];
|
|
31
31
|
comment?: string | undefined;
|
|
32
32
|
example?: ExampleDirective | undefined;
|
|
33
33
|
};
|
|
34
|
-
export type
|
|
34
|
+
export type UnionTypeInfo = {
|
|
35
|
+
type: "union";
|
|
36
|
+
name: string;
|
|
37
|
+
possibleTypes: string[];
|
|
38
|
+
example?: ExampleDirective | undefined;
|
|
39
|
+
};
|
|
40
|
+
export type TypeInfo = ObjectTypeInfo | InterfaceTypeInfo | EnumTypeInfo | UnionTypeInfo;
|
|
35
41
|
export type EnumMap = Map<string, TypeInfo>;
|
|
36
42
|
export declare function getTypeInfos(config: Config, schema: GraphQLSchema): TypeInfo[];
|
|
37
43
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-scanner.d.ts","sourceRoot":"","sources":["../../src/schema-scanner.ts"],"names":[],"mappings":"AACA,OAAO,EAKH,KAAK,aAAa,EAWrB,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAgD1C,KAAK,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AACvD,KAAK,UAAU,GAAG,cAAc,EAAE,CAAC;AACnC,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,GAAG,UAAU,CAAC,CAAC;AAC/D,MAAM,MAAM,qBAAqB,GAAG;IAEhC,KAAK,EAAE,cAAc,GAAG,UAAU,GAAG,WAAW,CAAC;CACpD,CAAC;AACF,MAAM,MAAM,0BAA0B,GAAG;IACrC,UAAU,EAAE,MAAM,CAAC;CACtB,CAAC;AACF,MAAM,MAAM,gBAAgB,GAAG,qBAAqB,GAAG,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"schema-scanner.d.ts","sourceRoot":"","sources":["../../src/schema-scanner.ts"],"names":[],"mappings":"AACA,OAAO,EAKH,KAAK,aAAa,EAWrB,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAgD1C,KAAK,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AACvD,KAAK,UAAU,GAAG,cAAc,EAAE,CAAC;AACnC,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,GAAG,UAAU,CAAC,CAAC;A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,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,QAAQ,EAAE,CAI9E"}
|
|
@@ -183,6 +183,12 @@ const SUPPORTED_EXAMPLE_DIRECTIVES = [
|
|
|
183
183
|
"exampleInt",
|
|
184
184
|
"exampleFloat",
|
|
185
185
|
"exampleBoolean",
|
|
186
|
+
// array
|
|
187
|
+
"exampleArrayID",
|
|
188
|
+
"exampleArrayString",
|
|
189
|
+
"exampleArrayInt",
|
|
190
|
+
"exampleArrayFloat",
|
|
191
|
+
"exampleArrayBoolean",
|
|
186
192
|
];
|
|
187
193
|
const isIdType = (node) => {
|
|
188
194
|
if (node.kind === "NonNullType") {
|
|
@@ -219,6 +225,85 @@ function parseFieldOrInputValueDefinition({ node, convertedTypeName, config, idF
|
|
|
219
225
|
if (!exampleDirective.arguments) {
|
|
220
226
|
throw new Error(`@${exampleDirective.name.value} directive must have arguments. @${exampleDirective.name.value}(value: ...)`);
|
|
221
227
|
}
|
|
228
|
+
// [String!]! -> true
|
|
229
|
+
// [String!] -> true
|
|
230
|
+
// String -> false
|
|
231
|
+
const isListTypeNode = (node) => {
|
|
232
|
+
if (node.kind === "ListType") {
|
|
233
|
+
return true;
|
|
234
|
+
}
|
|
235
|
+
if (node.kind === "NonNullType") {
|
|
236
|
+
return isListTypeNode(node.type);
|
|
237
|
+
}
|
|
238
|
+
return false;
|
|
239
|
+
};
|
|
240
|
+
if (isListTypeNode(node.type)) {
|
|
241
|
+
/**
|
|
242
|
+
* @exampleArrayID(values: ["id1", "id2"])
|
|
243
|
+
* -> { values: ["id1", "id2"] }
|
|
244
|
+
* @exampleArrayString(values: ["value 1", "value 2"])
|
|
245
|
+
* -> { values: ["value 1", "value 2"] }
|
|
246
|
+
* @exampleArrayInt(values: [1, 2])
|
|
247
|
+
* -> { values: [1, 2] }
|
|
248
|
+
* @exampleArrayFloat(values: [1.1, 2.2])
|
|
249
|
+
* -> { values: [1.1, 2.2] }
|
|
250
|
+
* @exampleArrayBoolean(values: [true, false])
|
|
251
|
+
* -> { values: [true, false] }
|
|
252
|
+
*/
|
|
253
|
+
const exampleDirectiveValues = exampleDirective.arguments.find((a) => a.name.value === "values");
|
|
254
|
+
if (!exampleDirectiveValues) {
|
|
255
|
+
throw new Error(`@${exampleDirective.name.value} directive must have values argument. @${exampleDirective.name.value}(values: ...)`);
|
|
256
|
+
}
|
|
257
|
+
if (exampleDirectiveValues.value.kind !== "ListValue") {
|
|
258
|
+
throw new Error(`@${exampleDirective.name.value} directive must have values argument. @${exampleDirective.name.value}(values: ...). values is not array.`);
|
|
259
|
+
}
|
|
260
|
+
// [String!]! -> String
|
|
261
|
+
// [String!] -> String
|
|
262
|
+
const unwrapListNodeType = (node) => {
|
|
263
|
+
if (node.kind === "ListType") {
|
|
264
|
+
return unwrapListNodeType(node.type);
|
|
265
|
+
}
|
|
266
|
+
if (node.kind === "NonNullType") {
|
|
267
|
+
return unwrapListNodeType(node.type);
|
|
268
|
+
}
|
|
269
|
+
return node;
|
|
270
|
+
};
|
|
271
|
+
const itemOfArrayNodeType = unwrapListNodeType(node.type);
|
|
272
|
+
const itemOfArrayRawValueType = parseTypeNodeStructure(itemOfArrayNodeType);
|
|
273
|
+
const exampleDirectiveRawValues = exampleDirectiveValues.value.values.map((v) => {
|
|
274
|
+
return valueOfNode(v);
|
|
275
|
+
}); // TODO: need to fix type
|
|
276
|
+
// all raw values should be the same type
|
|
277
|
+
const exampleDirectiveRawValueTypeSet = new Set([
|
|
278
|
+
...exampleDirectiveRawValues.map((value) => {
|
|
279
|
+
// array, object, string, number, boolean, null
|
|
280
|
+
return Object.prototype.toString.call(value).slice(8, -1).toLowerCase();
|
|
281
|
+
}),
|
|
282
|
+
]);
|
|
283
|
+
if (exampleDirectiveRawValueTypeSet.size !== 1) {
|
|
284
|
+
throw new Error(`${convertedTypeName}.${fieldName}: @${exampleDirective.name.value} directive values must be the same type. Got [${exampleDirectiveRawValues.join(", ")}]`);
|
|
285
|
+
}
|
|
286
|
+
// pick one of the raw value type
|
|
287
|
+
const oneOfExampleDirectiveRawValueType = exampleDirectiveRawValueTypeSet
|
|
288
|
+
.values()
|
|
289
|
+
.next().value;
|
|
290
|
+
if (itemOfArrayRawValueType !== oneOfExampleDirectiveRawValueType) {
|
|
291
|
+
throw new Error(`${convertedTypeName}.${fieldName}: @${exampleDirective.name.value} directive values type must be ${itemOfArrayRawValueType}. Got ${oneOfExampleDirectiveRawValueType}`);
|
|
292
|
+
}
|
|
293
|
+
// if ID type, add idFactory() to the value
|
|
294
|
+
// e.g. @exampleArrayID(values: ["id1", "id2"]) -> { expression: [__id("id1"), __id("id2")] }
|
|
295
|
+
const isExampleArrayIdDirective = exampleDirective.name.value === "exampleArrayID";
|
|
296
|
+
if (isExampleArrayIdDirective) {
|
|
297
|
+
const expressions = exampleDirectiveRawValues.flatMap((rawValue) => {
|
|
298
|
+
if (typeof rawValue !== "string") {
|
|
299
|
+
return [];
|
|
300
|
+
}
|
|
301
|
+
return idFactory(rawValue, `${convertedTypeName}.${fieldName}.${rawValue}`);
|
|
302
|
+
});
|
|
303
|
+
return { comment, example: { expression: `[${expressions.join(",")}]` } };
|
|
304
|
+
}
|
|
305
|
+
return { comment, example: { value: exampleDirectiveRawValues } };
|
|
306
|
+
}
|
|
222
307
|
/**
|
|
223
308
|
* @exampleID(value: "id")
|
|
224
309
|
* -> { value: "id1" }
|
|
@@ -231,26 +316,32 @@ function parseFieldOrInputValueDefinition({ node, convertedTypeName, config, idF
|
|
|
231
316
|
* @exampleBoolean(value: true)
|
|
232
317
|
* -> { value: true }
|
|
233
318
|
*/
|
|
234
|
-
const
|
|
235
|
-
if (!
|
|
319
|
+
const exampleDirectiveValue = exampleDirective.arguments.find((a) => a.name.value === "value");
|
|
320
|
+
if (!exampleDirectiveValue) {
|
|
236
321
|
throw new Error(`@${exampleDirective.name.value} directive must have value argument. @${exampleDirective.name.value}(value: ...)`);
|
|
237
322
|
}
|
|
238
|
-
const
|
|
323
|
+
const exampleDirectiveRawValue = valueOfNode(exampleDirectiveValue.value);
|
|
239
324
|
// if node type is not equal to the value type, throw an error
|
|
240
325
|
const nodeType = parseTypeNodeStructure(node.type);
|
|
241
326
|
// array, object, string, number, boolean, null
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
|
|
327
|
+
const directiveRawValueType = Object.prototype.toString
|
|
328
|
+
.call(exampleDirectiveRawValue)
|
|
329
|
+
.slice(8, -1)
|
|
330
|
+
.toLowerCase();
|
|
331
|
+
if (nodeType !== directiveRawValueType) {
|
|
332
|
+
throw new Error(`${convertedTypeName}.${fieldName}: @${exampleDirective.name.value} directive value type must be ${nodeType}. Got ${directiveRawValueType}`);
|
|
245
333
|
}
|
|
246
334
|
// if ID type, add idFactory() to the value
|
|
247
335
|
// e.g. @exampleID(value: "id") -> { expression: __id("id") }
|
|
248
336
|
const isExampleIdDirective = exampleDirective.name.value === "exampleID";
|
|
249
|
-
if (isExampleIdDirective && typeof
|
|
250
|
-
const pathOfField = `${convertedTypeName}.${fieldName}.${
|
|
251
|
-
return {
|
|
337
|
+
if (isExampleIdDirective && typeof exampleDirectiveRawValue === "string") {
|
|
338
|
+
const pathOfField = `${convertedTypeName}.${fieldName}.${exampleDirectiveRawValue}`;
|
|
339
|
+
return {
|
|
340
|
+
comment,
|
|
341
|
+
example: { expression: idFactory(exampleDirectiveRawValue, pathOfField) },
|
|
342
|
+
};
|
|
252
343
|
}
|
|
253
|
-
return { comment, example: { value:
|
|
344
|
+
return { comment, example: { value: exampleDirectiveRawValue } };
|
|
254
345
|
}
|
|
255
346
|
function parseObjectTypeOrInputObjectTypeDefinition({ node, config, idFactory, enumMap, }) {
|
|
256
347
|
const originalTypeName = node.name.value;
|
|
@@ -312,20 +403,21 @@ const createObjectTypeInfo = ({ config, schema, enumMap, }) => {
|
|
|
312
403
|
}
|
|
313
404
|
if (node?.kind === Kind.INTERFACE_TYPE_DEFINITION) {
|
|
314
405
|
return {
|
|
315
|
-
type: "
|
|
406
|
+
type: "interface",
|
|
316
407
|
name: convertName(node.name.value, config),
|
|
317
408
|
possibleTypes: objectTypeDefinitions
|
|
318
409
|
.filter((objectTypeDefinitionNode) => (objectTypeDefinitionNode.interfaces ?? []).some((i) => i.name.value === node.name.value))
|
|
319
410
|
.map((objectTypeDefinitionNode) => convertName(objectTypeDefinitionNode.name.value, config)),
|
|
320
|
-
comment: node.description ? transformComment(node.description) : undefined,
|
|
321
411
|
};
|
|
322
412
|
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
413
|
+
if (node?.kind === Kind.UNION_TYPE_DEFINITION) {
|
|
414
|
+
return {
|
|
415
|
+
type: "union",
|
|
416
|
+
name: convertName(node.name.value, config),
|
|
417
|
+
possibleTypes: (node.types ?? []).map((type) => convertName(type.name.value, config)),
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
throw new Error(`Unknown kind of node: ${node}`);
|
|
329
421
|
});
|
|
330
422
|
};
|
|
331
423
|
const createEnumTypeInfo = ({ config, schema, }) => {
|
|
@@ -333,7 +425,7 @@ const createEnumTypeInfo = ({ config, schema, }) => {
|
|
|
333
425
|
// https://astexplorer.net/#/gist/bbfe3f7414a904b453e173d82e836525/bab0cc96ffb951909dc3cf67a67bd67d09948be6
|
|
334
426
|
// Therefore, We need to create "object" type from EnumTypeDefinitionNode
|
|
335
427
|
// enum Color { RED, GREEN, BLUE }
|
|
336
|
-
// ->
|
|
428
|
+
// -> const Color = { RED: "RED", GREEN: "GREEN", BLUE: "BLUE" }
|
|
337
429
|
const types = Object.values(schema.getTypeMap());
|
|
338
430
|
const userDefinedEnumTypeDefinitions = types
|
|
339
431
|
.map((type) => type.astNode)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-scanner.js","sourceRoot":"","sources":["../../src/schema-scanner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1F,OAAO,E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AM,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;gBACxB,OAAO;oBACH,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK;oBACtB,OAAO,EAAE;wBACL,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK;qBAC1B;iBACJ,CAAC;YACN,CAAC,CAAC,IAAI,EAAE;SACf,CAAC;IACN,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,MAAM,UAAU,YAAY,CAAC,MAAc,EAAE,MAAqB;IAC9D,MAAM,YAAY,GAAG,kBAAkB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC5E,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACvE,OAAO,CAAC,GAAG,YAAY,EAAE,GAAG,oBAAoB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;AACnG,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newmo/graphql-fake-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "GraphQL fake core library",
|
|
6
6
|
"keywords": [
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"access": "public",
|
|
66
66
|
"registry": "https://registry.npmjs.org/"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "5c711a31d4fe1e4903686513a85d1921e268d2d4"
|
|
69
69
|
}
|
package/src/code-generator.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import type { Config } from "./config.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
EnumTypeInfo,
|
|
4
|
+
ExampleDirective,
|
|
5
|
+
InterfaceTypeInfo,
|
|
6
|
+
ObjectTypeInfo,
|
|
7
|
+
TypeInfo,
|
|
8
|
+
UnionTypeInfo,
|
|
9
|
+
} from "./schema-scanner.js";
|
|
3
10
|
|
|
4
11
|
export type ConfigWithOutput = {
|
|
5
12
|
outputType: "typescript" | "javascript" | "commonjs";
|
|
@@ -129,6 +136,46 @@ function __id({ name, key, depth }${
|
|
|
129
136
|
}`;
|
|
130
137
|
}
|
|
131
138
|
|
|
139
|
+
// Return first type of union type / interface
|
|
140
|
+
// union Author = User | Admin
|
|
141
|
+
// We can not understand which type should be returned
|
|
142
|
+
// As a result, we always return the first type of the union type/interface
|
|
143
|
+
function generateUnionOrInterfaceTypeCode(
|
|
144
|
+
config: ConfigWithOutput,
|
|
145
|
+
typeInfo: UnionTypeInfo | InterfaceTypeInfo,
|
|
146
|
+
): string {
|
|
147
|
+
const { name } = typeInfo;
|
|
148
|
+
const indent = " ";
|
|
149
|
+
const firstTypeNameOfUnionType = typeInfo.possibleTypes[0];
|
|
150
|
+
if (!firstTypeNameOfUnionType) {
|
|
151
|
+
throw new Error(`Union type ${name} has no possible types`);
|
|
152
|
+
}
|
|
153
|
+
// __typename is required for Union type
|
|
154
|
+
// https://stackoverflow.com/questions/59519816/abstract-type-x-must-resolve-to-an-object-type-at-runtime-for-field-query-user
|
|
155
|
+
// https://www.apollographql.com/docs/federation/entities/#2-define-a-reference-resolver
|
|
156
|
+
const functionBodyCode = `
|
|
157
|
+
${indent}return {
|
|
158
|
+
${indent}${indent}__typename: "${firstTypeNameOfUnionType}",
|
|
159
|
+
${indent}${indent}...${generateCreateReferenceCode({
|
|
160
|
+
typeName: firstTypeNameOfUnionType,
|
|
161
|
+
fieldName: typeInfo.name,
|
|
162
|
+
config,
|
|
163
|
+
})}
|
|
164
|
+
};
|
|
165
|
+
`.trim();
|
|
166
|
+
if (config.outputType === "typescript") {
|
|
167
|
+
return `
|
|
168
|
+
export function create${name}({ defaultFields, depth = 0 }: { defaultFields?: Partial<${name}>, depth?: number } = {}): ${name} {
|
|
169
|
+
${functionBodyCode}
|
|
170
|
+
}
|
|
171
|
+
`.trim();
|
|
172
|
+
}
|
|
173
|
+
return `
|
|
174
|
+
function create${name}({ defaultFields, depth = 0 } = {}) {
|
|
175
|
+
${functionBodyCode}
|
|
176
|
+
}`;
|
|
177
|
+
}
|
|
178
|
+
|
|
132
179
|
export function generateCode(config: ConfigWithOutput, typeInfos: TypeInfo[]): string {
|
|
133
180
|
let code = "";
|
|
134
181
|
if (config.outputType === "typescript") {
|
|
@@ -144,6 +191,10 @@ export function generateCode(config: ConfigWithOutput, typeInfos: TypeInfo[]): s
|
|
|
144
191
|
}
|
|
145
192
|
}
|
|
146
193
|
for (const typeInfo of typeInfos) {
|
|
194
|
+
if (typeInfo.type === "union" || typeInfo.type === "interface") {
|
|
195
|
+
code += generateUnionOrInterfaceTypeCode(config, typeInfo);
|
|
196
|
+
code += "\n";
|
|
197
|
+
}
|
|
147
198
|
if (typeInfo.type === "object") {
|
|
148
199
|
code += generateFactoryCode(config, typeInfo);
|
|
149
200
|
code += "\n";
|
package/src/createMock.ts
CHANGED
|
@@ -2,7 +2,7 @@ import vm from "node:vm";
|
|
|
2
2
|
import type { GraphQLSchema } from "graphql/index.js";
|
|
3
3
|
import { generateCode } from "./code-generator.js";
|
|
4
4
|
import { normalizeConfig } from "./config.js";
|
|
5
|
-
import { getTypeInfos } from "./schema-scanner.js";
|
|
5
|
+
import { type TypeInfo, getTypeInfos } from "./schema-scanner.js";
|
|
6
6
|
|
|
7
7
|
export type MockObject = Record<string, unknown>;
|
|
8
8
|
export type CreateMockOptions = {
|
|
@@ -21,6 +21,7 @@ export type CreateMockResult =
|
|
|
21
21
|
| {
|
|
22
22
|
ok: false;
|
|
23
23
|
code: string;
|
|
24
|
+
typeInfos: TypeInfo[];
|
|
24
25
|
error: Error;
|
|
25
26
|
};
|
|
26
27
|
/**
|
|
@@ -54,6 +55,7 @@ export const createMock = async (options: CreateMockOptions): Promise<CreateMock
|
|
|
54
55
|
return {
|
|
55
56
|
ok: false,
|
|
56
57
|
code,
|
|
58
|
+
typeInfos,
|
|
57
59
|
error: error as Error,
|
|
58
60
|
};
|
|
59
61
|
}
|
package/src/extend-schema.ts
CHANGED
|
@@ -55,6 +55,63 @@ directive @exampleBoolean(
|
|
|
55
55
|
"""
|
|
56
56
|
value: Boolean!
|
|
57
57
|
) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION
|
|
58
|
+
|
|
59
|
+
"""
|
|
60
|
+
@exampleArrayID directive specifies an example value for a array of ID field.
|
|
61
|
+
This example value is used in the fake data.
|
|
62
|
+
ID value will be unique between all ID fake data.
|
|
63
|
+
"""
|
|
64
|
+
directive @exampleArrayID(
|
|
65
|
+
"""
|
|
66
|
+
The value of the ID field.
|
|
67
|
+
@exampleArrayID(value: ["id1", "id2"])
|
|
68
|
+
"""
|
|
69
|
+
values: [ID!]!
|
|
70
|
+
) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION
|
|
71
|
+
"""
|
|
72
|
+
@exampleArrayString directive specifies an example value for a array of String field.
|
|
73
|
+
This example value is used in the fake data.
|
|
74
|
+
"""
|
|
75
|
+
directive @exampleArrayString(
|
|
76
|
+
"""
|
|
77
|
+
The value of the String field.
|
|
78
|
+
@exampleArrayString(value: ["example1", "example2"])
|
|
79
|
+
"""
|
|
80
|
+
values: [String!]!
|
|
81
|
+
) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION
|
|
82
|
+
"""
|
|
83
|
+
@exampleArrayInt directive specifies an example value for a array of Int field.
|
|
84
|
+
This example value is used in the fake data.
|
|
85
|
+
"""
|
|
86
|
+
directive @exampleArrayInt(
|
|
87
|
+
"""
|
|
88
|
+
The value of the Int field.
|
|
89
|
+
@exampleArrayInt(value: [1, 2])
|
|
90
|
+
"""
|
|
91
|
+
values: [Int!]!
|
|
92
|
+
) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION
|
|
93
|
+
"""
|
|
94
|
+
@exampleArrayFloat directive specifies an example value for a array of Float field.
|
|
95
|
+
This example value is used in the fake data.
|
|
96
|
+
"""
|
|
97
|
+
directive @exampleArrayFloat(
|
|
98
|
+
"""
|
|
99
|
+
The value of the Float field.
|
|
100
|
+
@exampleArrayFloat(value: [1.0, 2.0])
|
|
101
|
+
"""
|
|
102
|
+
values: [Float!]!
|
|
103
|
+
) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION
|
|
104
|
+
"""
|
|
105
|
+
@exampleArrayBoolean directive specifies an example value for a array of Boolean field.
|
|
106
|
+
This example value is used in the fake data.
|
|
107
|
+
"""
|
|
108
|
+
directive @exampleArrayBoolean(
|
|
109
|
+
"""
|
|
110
|
+
The value of the Boolean field.
|
|
111
|
+
@exampleArrayBoolean(value: [true, false])
|
|
112
|
+
"""
|
|
113
|
+
values: [Boolean!]!
|
|
114
|
+
) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION
|
|
58
115
|
`;
|
|
59
116
|
export const extendSchema = (schema: string) => {
|
|
60
117
|
return EXAMPLE_DIRECTIVE + schema;
|
package/src/index.ts
CHANGED
package/src/schema-scanner.ts
CHANGED
|
@@ -263,6 +263,12 @@ const SUPPORTED_EXAMPLE_DIRECTIVES = [
|
|
|
263
263
|
"exampleInt",
|
|
264
264
|
"exampleFloat",
|
|
265
265
|
"exampleBoolean",
|
|
266
|
+
// array
|
|
267
|
+
"exampleArrayID",
|
|
268
|
+
"exampleArrayString",
|
|
269
|
+
"exampleArrayInt",
|
|
270
|
+
"exampleArrayFloat",
|
|
271
|
+
"exampleArrayBoolean",
|
|
266
272
|
];
|
|
267
273
|
const isIdType = (node: NonNullTypeNode | NamedTypeNode | ListTypeNode): boolean => {
|
|
268
274
|
if (node.kind === "NonNullType") {
|
|
@@ -314,6 +320,99 @@ function parseFieldOrInputValueDefinition({
|
|
|
314
320
|
`@${exampleDirective.name.value} directive must have arguments. @${exampleDirective.name.value}(value: ...)`,
|
|
315
321
|
);
|
|
316
322
|
}
|
|
323
|
+
// [String!]! -> true
|
|
324
|
+
// [String!] -> true
|
|
325
|
+
// String -> false
|
|
326
|
+
const isListTypeNode = (node: TypeNode): node is ListTypeNode | NonNullTypeNode => {
|
|
327
|
+
if (node.kind === "ListType") {
|
|
328
|
+
return true;
|
|
329
|
+
}
|
|
330
|
+
if (node.kind === "NonNullType") {
|
|
331
|
+
return isListTypeNode(node.type);
|
|
332
|
+
}
|
|
333
|
+
return false;
|
|
334
|
+
};
|
|
335
|
+
if (isListTypeNode(node.type)) {
|
|
336
|
+
/**
|
|
337
|
+
* @exampleArrayID(values: ["id1", "id2"])
|
|
338
|
+
* -> { values: ["id1", "id2"] }
|
|
339
|
+
* @exampleArrayString(values: ["value 1", "value 2"])
|
|
340
|
+
* -> { values: ["value 1", "value 2"] }
|
|
341
|
+
* @exampleArrayInt(values: [1, 2])
|
|
342
|
+
* -> { values: [1, 2] }
|
|
343
|
+
* @exampleArrayFloat(values: [1.1, 2.2])
|
|
344
|
+
* -> { values: [1.1, 2.2] }
|
|
345
|
+
* @exampleArrayBoolean(values: [true, false])
|
|
346
|
+
* -> { values: [true, false] }
|
|
347
|
+
*/
|
|
348
|
+
const exampleDirectiveValues = exampleDirective.arguments.find(
|
|
349
|
+
(a) => a.name.value === "values",
|
|
350
|
+
);
|
|
351
|
+
if (!exampleDirectiveValues) {
|
|
352
|
+
throw new Error(
|
|
353
|
+
`@${exampleDirective.name.value} directive must have values argument. @${exampleDirective.name.value}(values: ...)`,
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
if (exampleDirectiveValues.value.kind !== "ListValue") {
|
|
357
|
+
throw new Error(
|
|
358
|
+
`@${exampleDirective.name.value} directive must have values argument. @${exampleDirective.name.value}(values: ...). values is not array.`,
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
// [String!]! -> String
|
|
362
|
+
// [String!] -> String
|
|
363
|
+
const unwrapListNodeType = (node: ListTypeNode | NonNullTypeNode | TypeNode): TypeNode => {
|
|
364
|
+
if (node.kind === "ListType") {
|
|
365
|
+
return unwrapListNodeType(node.type);
|
|
366
|
+
}
|
|
367
|
+
if (node.kind === "NonNullType") {
|
|
368
|
+
return unwrapListNodeType(node.type);
|
|
369
|
+
}
|
|
370
|
+
return node;
|
|
371
|
+
};
|
|
372
|
+
const itemOfArrayNodeType = unwrapListNodeType(node.type);
|
|
373
|
+
const itemOfArrayRawValueType = parseTypeNodeStructure(itemOfArrayNodeType);
|
|
374
|
+
const exampleDirectiveRawValues = exampleDirectiveValues.value.values.map((v) => {
|
|
375
|
+
return valueOfNode(v);
|
|
376
|
+
}) as ValuePrimitive[]; // TODO: need to fix type
|
|
377
|
+
// all raw values should be the same type
|
|
378
|
+
const exampleDirectiveRawValueTypeSet = new Set<string>([
|
|
379
|
+
...exampleDirectiveRawValues.map((value) => {
|
|
380
|
+
// array, object, string, number, boolean, null
|
|
381
|
+
return Object.prototype.toString.call(value).slice(8, -1).toLowerCase();
|
|
382
|
+
}),
|
|
383
|
+
]);
|
|
384
|
+
if (exampleDirectiveRawValueTypeSet.size !== 1) {
|
|
385
|
+
throw new Error(
|
|
386
|
+
`${convertedTypeName}.${fieldName}: @${
|
|
387
|
+
exampleDirective.name.value
|
|
388
|
+
} directive values must be the same type. Got [${exampleDirectiveRawValues.join(
|
|
389
|
+
", ",
|
|
390
|
+
)}]`,
|
|
391
|
+
);
|
|
392
|
+
}
|
|
393
|
+
// pick one of the raw value type
|
|
394
|
+
const oneOfExampleDirectiveRawValueType = exampleDirectiveRawValueTypeSet
|
|
395
|
+
.values()
|
|
396
|
+
.next().value;
|
|
397
|
+
if (itemOfArrayRawValueType !== oneOfExampleDirectiveRawValueType) {
|
|
398
|
+
throw new Error(
|
|
399
|
+
`${convertedTypeName}.${fieldName}: @${exampleDirective.name.value} directive values type must be ${itemOfArrayRawValueType}. Got ${oneOfExampleDirectiveRawValueType}`,
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
// if ID type, add idFactory() to the value
|
|
403
|
+
// e.g. @exampleArrayID(values: ["id1", "id2"]) -> { expression: [__id("id1"), __id("id2")] }
|
|
404
|
+
const isExampleArrayIdDirective = exampleDirective.name.value === "exampleArrayID";
|
|
405
|
+
if (isExampleArrayIdDirective) {
|
|
406
|
+
const expressions = exampleDirectiveRawValues.flatMap((rawValue) => {
|
|
407
|
+
if (typeof rawValue !== "string") {
|
|
408
|
+
return [];
|
|
409
|
+
}
|
|
410
|
+
return idFactory(rawValue, `${convertedTypeName}.${fieldName}.${rawValue}`);
|
|
411
|
+
});
|
|
412
|
+
return { comment, example: { expression: `[${expressions.join(",")}]` } };
|
|
413
|
+
}
|
|
414
|
+
return { comment, example: { value: exampleDirectiveRawValues } };
|
|
415
|
+
}
|
|
317
416
|
/**
|
|
318
417
|
* @exampleID(value: "id")
|
|
319
418
|
* -> { value: "id1" }
|
|
@@ -326,30 +425,36 @@ function parseFieldOrInputValueDefinition({
|
|
|
326
425
|
* @exampleBoolean(value: true)
|
|
327
426
|
* -> { value: true }
|
|
328
427
|
*/
|
|
329
|
-
const
|
|
330
|
-
if (!
|
|
428
|
+
const exampleDirectiveValue = exampleDirective.arguments.find((a) => a.name.value === "value");
|
|
429
|
+
if (!exampleDirectiveValue) {
|
|
331
430
|
throw new Error(
|
|
332
431
|
`@${exampleDirective.name.value} directive must have value argument. @${exampleDirective.name.value}(value: ...)`,
|
|
333
432
|
);
|
|
334
433
|
}
|
|
335
|
-
const
|
|
434
|
+
const exampleDirectiveRawValue = valueOfNode(exampleDirectiveValue.value);
|
|
336
435
|
// if node type is not equal to the value type, throw an error
|
|
337
436
|
const nodeType = parseTypeNodeStructure(node.type);
|
|
338
437
|
// array, object, string, number, boolean, null
|
|
339
|
-
const
|
|
340
|
-
|
|
438
|
+
const directiveRawValueType = Object.prototype.toString
|
|
439
|
+
.call(exampleDirectiveRawValue)
|
|
440
|
+
.slice(8, -1)
|
|
441
|
+
.toLowerCase();
|
|
442
|
+
if (nodeType !== directiveRawValueType) {
|
|
341
443
|
throw new Error(
|
|
342
|
-
`${convertedTypeName}.${fieldName}: @${exampleDirective.name.value} directive value type must be ${nodeType}. Got ${
|
|
444
|
+
`${convertedTypeName}.${fieldName}: @${exampleDirective.name.value} directive value type must be ${nodeType}. Got ${directiveRawValueType}`,
|
|
343
445
|
);
|
|
344
446
|
}
|
|
345
447
|
// if ID type, add idFactory() to the value
|
|
346
448
|
// e.g. @exampleID(value: "id") -> { expression: __id("id") }
|
|
347
449
|
const isExampleIdDirective = exampleDirective.name.value === "exampleID";
|
|
348
|
-
if (isExampleIdDirective && typeof
|
|
349
|
-
const pathOfField = `${convertedTypeName}.${fieldName}.${
|
|
350
|
-
return {
|
|
450
|
+
if (isExampleIdDirective && typeof exampleDirectiveRawValue === "string") {
|
|
451
|
+
const pathOfField = `${convertedTypeName}.${fieldName}.${exampleDirectiveRawValue}`;
|
|
452
|
+
return {
|
|
453
|
+
comment,
|
|
454
|
+
example: { expression: idFactory(exampleDirectiveRawValue, pathOfField) },
|
|
455
|
+
};
|
|
351
456
|
}
|
|
352
|
-
return { comment, example: { value:
|
|
457
|
+
return { comment, example: { value: exampleDirectiveRawValue } };
|
|
353
458
|
}
|
|
354
459
|
|
|
355
460
|
function parseObjectTypeOrInputObjectTypeDefinition({
|
|
@@ -397,14 +502,20 @@ export type EnumTypeInfo = {
|
|
|
397
502
|
name: string;
|
|
398
503
|
fields: FieldInfo[];
|
|
399
504
|
};
|
|
400
|
-
export type
|
|
401
|
-
type: "
|
|
505
|
+
export type InterfaceTypeInfo = {
|
|
506
|
+
type: "interface";
|
|
402
507
|
name: string;
|
|
403
508
|
possibleTypes: string[];
|
|
404
509
|
comment?: string | undefined;
|
|
405
510
|
example?: ExampleDirective | undefined;
|
|
406
511
|
};
|
|
407
|
-
export type
|
|
512
|
+
export type UnionTypeInfo = {
|
|
513
|
+
type: "union";
|
|
514
|
+
name: string;
|
|
515
|
+
possibleTypes: string[];
|
|
516
|
+
example?: ExampleDirective | undefined;
|
|
517
|
+
};
|
|
518
|
+
export type TypeInfo = ObjectTypeInfo | InterfaceTypeInfo | EnumTypeInfo | UnionTypeInfo;
|
|
408
519
|
export type EnumMap = Map<string, TypeInfo>;
|
|
409
520
|
const createObjectTypeInfo = ({
|
|
410
521
|
config,
|
|
@@ -472,11 +583,11 @@ const createObjectTypeInfo = ({
|
|
|
472
583
|
config,
|
|
473
584
|
idFactory,
|
|
474
585
|
enumMap,
|
|
475
|
-
});
|
|
586
|
+
}) satisfies ObjectTypeInfo;
|
|
476
587
|
}
|
|
477
588
|
if (node?.kind === Kind.INTERFACE_TYPE_DEFINITION) {
|
|
478
589
|
return {
|
|
479
|
-
type: "
|
|
590
|
+
type: "interface",
|
|
480
591
|
name: convertName(node.name.value, config),
|
|
481
592
|
possibleTypes: objectTypeDefinitions
|
|
482
593
|
.filter((objectTypeDefinitionNode) =>
|
|
@@ -487,17 +598,18 @@ const createObjectTypeInfo = ({
|
|
|
487
598
|
.map((objectTypeDefinitionNode) =>
|
|
488
599
|
convertName(objectTypeDefinitionNode.name.value, config),
|
|
489
600
|
),
|
|
490
|
-
|
|
491
|
-
};
|
|
601
|
+
} satisfies InterfaceTypeInfo;
|
|
492
602
|
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
603
|
+
if (node?.kind === Kind.UNION_TYPE_DEFINITION) {
|
|
604
|
+
return {
|
|
605
|
+
type: "union",
|
|
606
|
+
name: convertName(node.name.value, config),
|
|
607
|
+
possibleTypes: (node.types ?? []).map((type) =>
|
|
608
|
+
convertName(type.name.value, config),
|
|
609
|
+
),
|
|
610
|
+
} satisfies UnionTypeInfo;
|
|
611
|
+
}
|
|
612
|
+
throw new Error(`Unknown kind of node: ${node}`);
|
|
501
613
|
});
|
|
502
614
|
};
|
|
503
615
|
|
|
@@ -512,7 +624,7 @@ const createEnumTypeInfo = ({
|
|
|
512
624
|
// https://astexplorer.net/#/gist/bbfe3f7414a904b453e173d82e836525/bab0cc96ffb951909dc3cf67a67bd67d09948be6
|
|
513
625
|
// Therefore, We need to create "object" type from EnumTypeDefinitionNode
|
|
514
626
|
// enum Color { RED, GREEN, BLUE }
|
|
515
|
-
// ->
|
|
627
|
+
// -> const Color = { RED: "RED", GREEN: "GREEN", BLUE: "BLUE" }
|
|
516
628
|
const types = Object.values(schema.getTypeMap());
|
|
517
629
|
const userDefinedEnumTypeDefinitions = types
|
|
518
630
|
.map((type) => type.astNode)
|