@newmo/graphql-fake-server 0.16.0 → 0.16.1
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/dist/esm/cli.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newmo/graphql-fake-server",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "GraphQL fake server for testing",
|
|
6
6
|
"keywords": [
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@graphql-tools/mock": "^9.0.15",
|
|
52
52
|
"@graphql-tools/schema": "^10.0.16",
|
|
53
53
|
"@hono/node-server": "^1.13.8",
|
|
54
|
-
"@newmo/graphql-fake-core": "0.16.
|
|
54
|
+
"@newmo/graphql-fake-core": "0.16.1",
|
|
55
55
|
"graphql-depth-limit": "^1.1.0",
|
|
56
56
|
"hono": "^4.7.0"
|
|
57
57
|
},
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"access": "public",
|
|
76
76
|
"registry": "https://registry.npmjs.org/"
|
|
77
77
|
},
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "be5eeb67402002c45a85748027a373d1baaf743d"
|
|
79
79
|
}
|
package/dist/esm/createMock.d.ts
DELETED
|
File without changes
|
|
File without changes
|
package/dist/esm/createMock.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import vm from "node:vm";
|
|
2
|
-
import { generateCode, getTypeInfos, normalizeConfig } from "@newmo/graphql-fake-core";
|
|
3
|
-
import { createLogger } from "./logger.js";
|
|
4
|
-
const cloneAsJSON = (obj) => {
|
|
5
|
-
return JSON.parse(JSON.stringify(obj));
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Create mock object from schema
|
|
9
|
-
* It supports @example directive
|
|
10
|
-
* @param options
|
|
11
|
-
*/
|
|
12
|
-
export const createMock = async (options) => {
|
|
13
|
-
const logger = createLogger(options.logLevel);
|
|
14
|
-
try {
|
|
15
|
-
const normalizedConfig = normalizeConfig({
|
|
16
|
-
maxFieldRecursionDepth: options.maxFieldRecursionDepth ?? 3,
|
|
17
|
-
});
|
|
18
|
-
const typeInfos = getTypeInfos(normalizedConfig, options.schema);
|
|
19
|
-
const code = generateCode({
|
|
20
|
-
...normalizedConfig,
|
|
21
|
-
outputType: "commonjs",
|
|
22
|
-
}, typeInfos);
|
|
23
|
-
logger.debug("Generated code:");
|
|
24
|
-
logger.debug(code);
|
|
25
|
-
// execute code in vm and get all exports
|
|
26
|
-
const exports = {};
|
|
27
|
-
vm.runInNewContext(code, { exports });
|
|
28
|
-
// Apollo Server does not support Function type in mock object
|
|
29
|
-
const plainObject = cloneAsJSON(exports);
|
|
30
|
-
logger.debug("Exports:");
|
|
31
|
-
logger.debug(JSON.stringify(plainObject, null, 2));
|
|
32
|
-
return plainObject;
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
logger.error(error);
|
|
36
|
-
process.exit(1);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
//# sourceMappingURL=createMock.js.map
|
|
File without changes
|