@graphql-mesh/plugin-mock 1.0.0-alpha-20230523153903-5443a1139 → 1.0.0-alpha-20230523154127-518d8667d
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/cjs/index.js +4 -5
- package/esm/index.js +4 -5
- package/package.json +8 -5
package/cjs/index.js
CHANGED
|
@@ -14,7 +14,6 @@ function useMock(config) {
|
|
|
14
14
|
if (configIf) {
|
|
15
15
|
return {
|
|
16
16
|
onSchemaChange({ schema, replaceSchema }) {
|
|
17
|
-
var _a;
|
|
18
17
|
if (mockedSchemas.has(schema)) {
|
|
19
18
|
return;
|
|
20
19
|
}
|
|
@@ -26,11 +25,11 @@ function useMock(config) {
|
|
|
26
25
|
for (const typeName in typeMap) {
|
|
27
26
|
const type = typeMap[typeName];
|
|
28
27
|
const examples = type.extensions.examples;
|
|
29
|
-
if (examples
|
|
28
|
+
if (examples?.length) {
|
|
30
29
|
mocks[typeName] = () => examples[Math.floor(Math.random() * examples.length)];
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
|
-
if (
|
|
32
|
+
if (config?.mocks?.length) {
|
|
34
33
|
for (const fieldConfig of config.mocks) {
|
|
35
34
|
const fieldConfigIf = 'if' in fieldConfig ? fieldConfig.if : true;
|
|
36
35
|
if (fieldConfigIf) {
|
|
@@ -129,7 +128,7 @@ function useMock(config) {
|
|
|
129
128
|
}
|
|
130
129
|
}
|
|
131
130
|
const store = (0, mock_1.createMockStore)({ schema, mocks });
|
|
132
|
-
if (config
|
|
131
|
+
if (config?.initializeStore) {
|
|
133
132
|
const initializeStoreFn$ = (0, utils_1.loadFromModuleExportExpression)(config.initializeStore, {
|
|
134
133
|
cwd: config.baseDir,
|
|
135
134
|
defaultExportName: 'default',
|
|
@@ -143,7 +142,7 @@ function useMock(config) {
|
|
|
143
142
|
store,
|
|
144
143
|
mocks,
|
|
145
144
|
resolvers,
|
|
146
|
-
preserveResolvers: config
|
|
145
|
+
preserveResolvers: config?.preserveResolvers,
|
|
147
146
|
});
|
|
148
147
|
mockedSchemas.add(mockedSchema);
|
|
149
148
|
replaceSchema(mockedSchema);
|
package/esm/index.js
CHANGED
|
@@ -11,7 +11,6 @@ export default function useMock(config) {
|
|
|
11
11
|
if (configIf) {
|
|
12
12
|
return {
|
|
13
13
|
onSchemaChange({ schema, replaceSchema }) {
|
|
14
|
-
var _a;
|
|
15
14
|
if (mockedSchemas.has(schema)) {
|
|
16
15
|
return;
|
|
17
16
|
}
|
|
@@ -23,11 +22,11 @@ export default function useMock(config) {
|
|
|
23
22
|
for (const typeName in typeMap) {
|
|
24
23
|
const type = typeMap[typeName];
|
|
25
24
|
const examples = type.extensions.examples;
|
|
26
|
-
if (examples
|
|
25
|
+
if (examples?.length) {
|
|
27
26
|
mocks[typeName] = () => examples[Math.floor(Math.random() * examples.length)];
|
|
28
27
|
}
|
|
29
28
|
}
|
|
30
|
-
if (
|
|
29
|
+
if (config?.mocks?.length) {
|
|
31
30
|
for (const fieldConfig of config.mocks) {
|
|
32
31
|
const fieldConfigIf = 'if' in fieldConfig ? fieldConfig.if : true;
|
|
33
32
|
if (fieldConfigIf) {
|
|
@@ -126,7 +125,7 @@ export default function useMock(config) {
|
|
|
126
125
|
}
|
|
127
126
|
}
|
|
128
127
|
const store = createMockStore({ schema, mocks });
|
|
129
|
-
if (config
|
|
128
|
+
if (config?.initializeStore) {
|
|
130
129
|
const initializeStoreFn$ = loadFromModuleExportExpression(config.initializeStore, {
|
|
131
130
|
cwd: config.baseDir,
|
|
132
131
|
defaultExportName: 'default',
|
|
@@ -140,7 +139,7 @@ export default function useMock(config) {
|
|
|
140
139
|
store,
|
|
141
140
|
mocks,
|
|
142
141
|
resolvers,
|
|
143
|
-
preserveResolvers: config
|
|
142
|
+
preserveResolvers: config?.preserveResolvers,
|
|
144
143
|
});
|
|
145
144
|
mockedSchemas.add(mockedSchema);
|
|
146
145
|
replaceSchema(mockedSchema);
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/plugin-mock",
|
|
3
|
-
"version": "1.0.0-alpha-
|
|
3
|
+
"version": "1.0.0-alpha-20230523154127-518d8667d",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@graphql-mesh/cross-helpers": "0.4.0-alpha-
|
|
7
|
-
"@graphql-mesh/types": "1.0.0-alpha-
|
|
8
|
-
"@graphql-mesh/utils": "1.0.0-alpha-
|
|
6
|
+
"@graphql-mesh/cross-helpers": "0.4.0-alpha-20230523154127-518d8667d",
|
|
7
|
+
"@graphql-mesh/types": "1.0.0-alpha-20230523154127-518d8667d",
|
|
8
|
+
"@graphql-mesh/utils": "1.0.0-alpha-20230523154127-518d8667d",
|
|
9
9
|
"@graphql-tools/utils": "^9.2.1",
|
|
10
10
|
"graphql": "*",
|
|
11
11
|
"tslib": "^2.4.0"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@graphql-mesh/string-interpolation": "0.5.0-alpha-
|
|
14
|
+
"@graphql-mesh/string-interpolation": "0.5.0-alpha-20230523154127-518d8667d",
|
|
15
15
|
"@graphql-tools/mock": "^8.7.20",
|
|
16
16
|
"@graphql-tools/schema": "^9.0.18",
|
|
17
17
|
"faker": "5.5.3",
|
|
@@ -23,6 +23,9 @@
|
|
|
23
23
|
"directory": "packages/plugins/mock"
|
|
24
24
|
},
|
|
25
25
|
"license": "MIT",
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=16.0.0"
|
|
28
|
+
},
|
|
26
29
|
"main": "cjs/index.js",
|
|
27
30
|
"module": "esm/index.js",
|
|
28
31
|
"typings": "typings/index.d.ts",
|