@newmo/graphql-fake-server 0.13.0 → 0.14.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 +66 -5
- package/dist/esm/config.d.ts +10 -4
- package/dist/esm/config.d.ts.map +1 -1
- package/dist/esm/config.js +2 -2
- package/dist/esm/config.js.map +1 -1
- package/package.json +3 -3
- package/src/config.ts +12 -7
package/README.md
CHANGED
|
@@ -13,6 +13,27 @@ See <https://github.com/newmo-oss/graphql-fake-server>
|
|
|
13
13
|
- Support `/fake/called` API
|
|
14
14
|
- Support `/graphql` API
|
|
15
15
|
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
Usage: npx @newmo/graphql-fake-server --schema <path> [options]
|
|
20
|
+
|
|
21
|
+
Options:
|
|
22
|
+
|
|
23
|
+
--config <path> Path to a config file
|
|
24
|
+
--schema <path> Path to a schema file
|
|
25
|
+
--logLevel <logLevel> log level: debug, info, warn, error
|
|
26
|
+
--cwd <path> Current working directory
|
|
27
|
+
--help Show help
|
|
28
|
+
|
|
29
|
+
Examples:
|
|
30
|
+
|
|
31
|
+
# Provide a schema file - use default config
|
|
32
|
+
npx @newmo/graphql-fake-server --schema api.graphql
|
|
33
|
+
# Use a config file
|
|
34
|
+
npx @newmo/graphql-fake-server --config graphql-fake-server.config.js
|
|
35
|
+
```
|
|
36
|
+
|
|
16
37
|
## HTTP APIs
|
|
17
38
|
|
|
18
39
|
### `/graphql` and `/query`
|
|
@@ -88,6 +109,34 @@ const calledResponse = await fetch(`${urls.fakeServer}/fake/called`, {
|
|
|
88
109
|
|
|
89
110
|
## Config
|
|
90
111
|
|
|
112
|
+
You can customize the configuration by `--config` option.
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
npx @newmo/graphql-fake-server --config graphql-fake-server.config.mjs
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Example of the config file: `graphql-fake-server.config.mjs`
|
|
119
|
+
|
|
120
|
+
```js
|
|
121
|
+
export default {
|
|
122
|
+
schemaFilePath: "./api/api.graphql",
|
|
123
|
+
ports: {
|
|
124
|
+
fakeServer: 4000,
|
|
125
|
+
apolloServer: 4002,
|
|
126
|
+
},
|
|
127
|
+
maxRegisteredSequences: 1000,
|
|
128
|
+
maxFieldRecursionDepth: 9,
|
|
129
|
+
maxQueryDepth: 10,
|
|
130
|
+
defaultValues: {
|
|
131
|
+
String: "string",
|
|
132
|
+
Int: 1,
|
|
133
|
+
Float: 1.1,
|
|
134
|
+
Boolean: true,
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
|
|
91
140
|
Please See [src/config.ts](src/config.ts)
|
|
92
141
|
|
|
93
142
|
```ts
|
|
@@ -96,10 +145,14 @@ Please See [src/config.ts](src/config.ts)
|
|
|
96
145
|
*/
|
|
97
146
|
export type FakeServerConfig = {
|
|
98
147
|
/**
|
|
99
|
-
* The path to the GraphQL schema file.
|
|
148
|
+
* The path to the GraphQL schema file from cwd.
|
|
100
149
|
*/
|
|
101
150
|
schemaFilePath: string;
|
|
102
|
-
|
|
151
|
+
/**
|
|
152
|
+
* The ports for the fake server and Apollo Server.
|
|
153
|
+
*/
|
|
154
|
+
ports?:
|
|
155
|
+
| {
|
|
103
156
|
/**
|
|
104
157
|
* Fake Server port.
|
|
105
158
|
* Default is 4000.
|
|
@@ -111,7 +164,8 @@ export type FakeServerConfig = {
|
|
|
111
164
|
* Default is 4002.
|
|
112
165
|
*/
|
|
113
166
|
apolloServer?: number | undefined;
|
|
114
|
-
}
|
|
167
|
+
}
|
|
168
|
+
| undefined;
|
|
115
169
|
/**
|
|
116
170
|
* The maximum number of registered sequences.
|
|
117
171
|
* Default is 1000.
|
|
@@ -119,18 +173,25 @@ export type FakeServerConfig = {
|
|
|
119
173
|
maxRegisteredSequences?: number | undefined;
|
|
120
174
|
/**
|
|
121
175
|
* The maximum number of depth of field recursion.
|
|
122
|
-
* Default is
|
|
176
|
+
* Default is 9.
|
|
123
177
|
*/
|
|
124
178
|
maxFieldRecursionDepth?: RawConfig["maxFieldRecursionDepth"] | undefined;
|
|
125
179
|
/**
|
|
126
180
|
* The maximum number of depth of complexity of query
|
|
127
|
-
*
|
|
181
|
+
* this value should be maxFieldRecursionDepth + 1
|
|
182
|
+
* Default is 10
|
|
128
183
|
*/
|
|
129
184
|
maxQueryDepth?: number | undefined;
|
|
130
185
|
/**
|
|
131
186
|
* Default values for scalar types.
|
|
132
187
|
*/
|
|
133
188
|
defaultValues?: RawConfig["defaultValues"] | undefined;
|
|
189
|
+
/**
|
|
190
|
+
* Log level: "debug", "info", "warn", "error"
|
|
191
|
+
* If you want to see the debug logs, set the logLevel to "debug".
|
|
192
|
+
* Default is "info".
|
|
193
|
+
*/
|
|
194
|
+
logLevel?: LogLevel | undefined;
|
|
134
195
|
};
|
|
135
196
|
```
|
|
136
197
|
|
package/dist/esm/config.d.ts
CHANGED
|
@@ -5,9 +5,12 @@ import type { LogLevel } from "./logger.js";
|
|
|
5
5
|
*/
|
|
6
6
|
export type FakeServerConfig = {
|
|
7
7
|
/**
|
|
8
|
-
* The path to the GraphQL schema file.
|
|
8
|
+
* The path to the GraphQL schema file from cwd.
|
|
9
9
|
*/
|
|
10
10
|
schemaFilePath: string;
|
|
11
|
+
/**
|
|
12
|
+
* The ports for the fake server and Apollo Server.
|
|
13
|
+
*/
|
|
11
14
|
ports?: {
|
|
12
15
|
/**
|
|
13
16
|
* Fake Server port.
|
|
@@ -28,12 +31,13 @@ export type FakeServerConfig = {
|
|
|
28
31
|
maxRegisteredSequences?: number | undefined;
|
|
29
32
|
/**
|
|
30
33
|
* The maximum number of depth of field recursion.
|
|
31
|
-
* Default is
|
|
34
|
+
* Default is 9.
|
|
32
35
|
*/
|
|
33
36
|
maxFieldRecursionDepth?: RawConfig["maxFieldRecursionDepth"] | undefined;
|
|
34
37
|
/**
|
|
35
38
|
* The maximum number of depth of complexity of query
|
|
36
|
-
*
|
|
39
|
+
* this value should be maxFieldRecursionDepth + 1
|
|
40
|
+
* Default is 10
|
|
37
41
|
*/
|
|
38
42
|
maxQueryDepth?: number | undefined;
|
|
39
43
|
/**
|
|
@@ -41,7 +45,9 @@ export type FakeServerConfig = {
|
|
|
41
45
|
*/
|
|
42
46
|
defaultValues?: RawConfig["defaultValues"] | undefined;
|
|
43
47
|
/**
|
|
44
|
-
* Log level
|
|
48
|
+
* Log level: "debug", "info", "warn", "error"
|
|
49
|
+
* If you want to see the debug logs, set the logLevel to "debug".
|
|
50
|
+
* Default is "info".
|
|
45
51
|
*/
|
|
46
52
|
logLevel?: LogLevel | undefined;
|
|
47
53
|
};
|
package/dist/esm/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC3B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,KAAK,CAAC,EACA;QACI;;;WAGG;QACH,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAChC;;;;WAIG;QACH,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KACrC,GACD,SAAS,CAAC;IAChB;;;OAGG;IACH,sBAAsB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5C;;;OAGG;IACH,sBAAsB,CAAC,EAAE,SAAS,CAAC,wBAAwB,CAAC,GAAG,SAAS,CAAC;IACzE;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC;;OAEG;IACH,aAAa,CAAC,EAAE,SAAS,CAAC,eAAe,CAAC,GAAG,SAAS,CAAC;IACvD;;;;OAIG;IACH,QAAQ,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CACnC,CAAC;AACF,MAAM,MAAM,wBAAwB,GAAG;IACnC,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE;QACH,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE,MAAM,CAAC;KACxB,CAAC;IACF,sBAAsB,EAAE,MAAM,CAAC;IAC/B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,SAAS,CAAC,eAAe,CAAC,CAAC;IAC1C,QAAQ,EAAE,QAAQ,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,yBAAyB,WAAY,gBAAgB,KAAG,wBAapE,CAAC;AACF,eAAO,MAAM,wBAAwB,WAAY,gBAAgB,KAAG,gBAqCnE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,UAAU,QACd,MAAM,cACC,MAAM,KACnB,QAAQ,wBAAwB,CAMlC,CAAC;AACF;;;GAGG;AACH,eAAO,MAAM,2BAA2B,kCAGrC;IACC,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CACnC,KAAG,wBAYH,CAAC"}
|
package/dist/esm/config.js
CHANGED
|
@@ -8,8 +8,8 @@ export const normalizeFakeServerConfig = (config) => {
|
|
|
8
8
|
apolloServer: config.ports?.apolloServer ?? 4002,
|
|
9
9
|
},
|
|
10
10
|
maxRegisteredSequences: config.maxRegisteredSequences ?? 1000,
|
|
11
|
-
maxFieldRecursionDepth: config.maxFieldRecursionDepth ??
|
|
12
|
-
maxQueryDepth: config.maxQueryDepth ??
|
|
11
|
+
maxFieldRecursionDepth: config.maxFieldRecursionDepth ?? 9,
|
|
12
|
+
maxQueryDepth: config.maxQueryDepth ?? 10,
|
|
13
13
|
defaultValues: config.defaultValues ?? {},
|
|
14
14
|
logLevel: config.logLevel ?? "info",
|
|
15
15
|
};
|
package/dist/esm/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAsEzC,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,MAAwB,EAA4B,EAAE;IAC5F,OAAO;QACH,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,KAAK,EAAE;YACH,UAAU,EAAE,MAAM,CAAC,KAAK,EAAE,UAAU,IAAI,IAAI;YAC5C,YAAY,EAAE,MAAM,CAAC,KAAK,EAAE,YAAY,IAAI,IAAI;SACnD;QACD,sBAAsB,EAAE,MAAM,CAAC,sBAAsB,IAAI,IAAI;QAC7D,sBAAsB,EAAE,MAAM,CAAC,sBAAsB,IAAI,CAAC;QAC1D,aAAa,EAAE,MAAM,CAAC,aAAa,IAAI,EAAE;QACzC,aAAa,EAAE,MAAM,CAAC,aAAa,IAAI,EAAE;QACzC,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,MAAM;KACtC,CAAC;AACN,CAAC,CAAC;AACF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,MAAwB,EAAoB,EAAE;IACnF,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACvD,CAAC;IACD,IAAI,OAAO,MAAM,CAAC,c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": false,
|
|
5
5
|
"description": "GraphQL fake server for testing",
|
|
6
6
|
"keywords": [
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@graphql-tools/mock": "^9.0.2",
|
|
52
52
|
"@graphql-tools/schema": "^10.0.3",
|
|
53
53
|
"@hono/node-server": "^1.11.1",
|
|
54
|
-
"@newmo/graphql-fake-core": "0.
|
|
54
|
+
"@newmo/graphql-fake-core": "0.14.0",
|
|
55
55
|
"graphql-depth-limit": "^1.1.0",
|
|
56
56
|
"hono": "^4.3.2"
|
|
57
57
|
},
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"access": "public",
|
|
78
78
|
"registry": "https://registry.npmjs.org/"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "b9817caa0b36489d9a2329be75adc99aa7b628c1"
|
|
81
81
|
}
|
package/src/config.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { pathToFileURL } from "node:url";
|
|
3
3
|
import type { RawConfig } from "@newmo/graphql-fake-core";
|
|
4
|
-
import { configDefaults } from "vitest/config";
|
|
5
4
|
import type { LogLevel } from "./logger.js";
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -9,9 +8,12 @@ import type { LogLevel } from "./logger.js";
|
|
|
9
8
|
*/
|
|
10
9
|
export type FakeServerConfig = {
|
|
11
10
|
/**
|
|
12
|
-
* The path to the GraphQL schema file.
|
|
11
|
+
* The path to the GraphQL schema file from cwd.
|
|
13
12
|
*/
|
|
14
13
|
schemaFilePath: string;
|
|
14
|
+
/**
|
|
15
|
+
* The ports for the fake server and Apollo Server.
|
|
16
|
+
*/
|
|
15
17
|
ports?:
|
|
16
18
|
| {
|
|
17
19
|
/**
|
|
@@ -34,12 +36,13 @@ export type FakeServerConfig = {
|
|
|
34
36
|
maxRegisteredSequences?: number | undefined;
|
|
35
37
|
/**
|
|
36
38
|
* The maximum number of depth of field recursion.
|
|
37
|
-
* Default is
|
|
39
|
+
* Default is 9.
|
|
38
40
|
*/
|
|
39
41
|
maxFieldRecursionDepth?: RawConfig["maxFieldRecursionDepth"] | undefined;
|
|
40
42
|
/**
|
|
41
43
|
* The maximum number of depth of complexity of query
|
|
42
|
-
*
|
|
44
|
+
* this value should be maxFieldRecursionDepth + 1
|
|
45
|
+
* Default is 10
|
|
43
46
|
*/
|
|
44
47
|
maxQueryDepth?: number | undefined;
|
|
45
48
|
/**
|
|
@@ -47,7 +50,9 @@ export type FakeServerConfig = {
|
|
|
47
50
|
*/
|
|
48
51
|
defaultValues?: RawConfig["defaultValues"] | undefined;
|
|
49
52
|
/**
|
|
50
|
-
* Log level
|
|
53
|
+
* Log level: "debug", "info", "warn", "error"
|
|
54
|
+
* If you want to see the debug logs, set the logLevel to "debug".
|
|
55
|
+
* Default is "info".
|
|
51
56
|
*/
|
|
52
57
|
logLevel?: LogLevel | undefined;
|
|
53
58
|
};
|
|
@@ -72,8 +77,8 @@ export const normalizeFakeServerConfig = (config: FakeServerConfig): RequiredFak
|
|
|
72
77
|
apolloServer: config.ports?.apolloServer ?? 4002,
|
|
73
78
|
},
|
|
74
79
|
maxRegisteredSequences: config.maxRegisteredSequences ?? 1000,
|
|
75
|
-
maxFieldRecursionDepth: config.maxFieldRecursionDepth ??
|
|
76
|
-
maxQueryDepth: config.maxQueryDepth ??
|
|
80
|
+
maxFieldRecursionDepth: config.maxFieldRecursionDepth ?? 9,
|
|
81
|
+
maxQueryDepth: config.maxQueryDepth ?? 10,
|
|
77
82
|
defaultValues: config.defaultValues ?? {},
|
|
78
83
|
logLevel: config.logLevel ?? "info",
|
|
79
84
|
};
|