@graphql-tools/mock 8.4.1-alpha-be1b2ebd.0 → 8.4.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/README.md +1 -1
- package/index.js +12 -6
- package/index.mjs +12 -6
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Check API Reference for more information about this package;
|
|
2
|
-
https://www.graphql-tools.com/docs/api/modules/
|
|
2
|
+
https://www.graphql-tools.com/docs/api/modules/mock_src
|
|
3
3
|
|
|
4
4
|
You can also learn more about Mocking in this chapter;
|
|
5
5
|
https://www.graphql-tools.com/docs/mocking
|
package/index.js
CHANGED
|
@@ -283,6 +283,12 @@ class MockStore {
|
|
|
283
283
|
if (isMockList(value)) {
|
|
284
284
|
value = deepResolveMockList(value);
|
|
285
285
|
}
|
|
286
|
+
if (this.store[typeName] === undefined) {
|
|
287
|
+
this.store[typeName] = {};
|
|
288
|
+
}
|
|
289
|
+
if (this.store[typeName][key] === undefined) {
|
|
290
|
+
this.store[typeName][key] = {};
|
|
291
|
+
}
|
|
286
292
|
if (!fieldName) {
|
|
287
293
|
if (!isRecord(value)) {
|
|
288
294
|
throw new Error('When no `fieldName` is provided, `value` should be a record.');
|
|
@@ -302,12 +308,6 @@ class MockStore {
|
|
|
302
308
|
if (this.isKeyField(typeName, fieldName) && value !== key) {
|
|
303
309
|
throw new Error(`Field ${fieldName} is a key field of ${typeName} and you are trying to set it to ${value} while the key is ${key}`);
|
|
304
310
|
}
|
|
305
|
-
if (this.store[typeName] === undefined) {
|
|
306
|
-
this.store[typeName] = {};
|
|
307
|
-
}
|
|
308
|
-
if (this.store[typeName][key] === undefined) {
|
|
309
|
-
this.store[typeName][key] = {};
|
|
310
|
-
}
|
|
311
311
|
// if already set and we don't override
|
|
312
312
|
if (this.store[typeName][key][fieldNameInStore] !== undefined && noOverride) {
|
|
313
313
|
return;
|
|
@@ -400,6 +400,12 @@ class MockStore {
|
|
|
400
400
|
noOverride,
|
|
401
401
|
});
|
|
402
402
|
}
|
|
403
|
+
if (this.store[typeName] === undefined) {
|
|
404
|
+
this.store[typeName] = {};
|
|
405
|
+
}
|
|
406
|
+
if (this.store[typeName][key] === undefined) {
|
|
407
|
+
this.store[typeName][key] = {};
|
|
408
|
+
}
|
|
403
409
|
return makeRef(typeName, key);
|
|
404
410
|
}
|
|
405
411
|
generateFieldValue(typeName, fieldName, onOtherFieldsGenerated) {
|
package/index.mjs
CHANGED
|
@@ -277,6 +277,12 @@ class MockStore {
|
|
|
277
277
|
if (isMockList(value)) {
|
|
278
278
|
value = deepResolveMockList(value);
|
|
279
279
|
}
|
|
280
|
+
if (this.store[typeName] === undefined) {
|
|
281
|
+
this.store[typeName] = {};
|
|
282
|
+
}
|
|
283
|
+
if (this.store[typeName][key] === undefined) {
|
|
284
|
+
this.store[typeName][key] = {};
|
|
285
|
+
}
|
|
280
286
|
if (!fieldName) {
|
|
281
287
|
if (!isRecord(value)) {
|
|
282
288
|
throw new Error('When no `fieldName` is provided, `value` should be a record.');
|
|
@@ -296,12 +302,6 @@ class MockStore {
|
|
|
296
302
|
if (this.isKeyField(typeName, fieldName) && value !== key) {
|
|
297
303
|
throw new Error(`Field ${fieldName} is a key field of ${typeName} and you are trying to set it to ${value} while the key is ${key}`);
|
|
298
304
|
}
|
|
299
|
-
if (this.store[typeName] === undefined) {
|
|
300
|
-
this.store[typeName] = {};
|
|
301
|
-
}
|
|
302
|
-
if (this.store[typeName][key] === undefined) {
|
|
303
|
-
this.store[typeName][key] = {};
|
|
304
|
-
}
|
|
305
305
|
// if already set and we don't override
|
|
306
306
|
if (this.store[typeName][key][fieldNameInStore] !== undefined && noOverride) {
|
|
307
307
|
return;
|
|
@@ -394,6 +394,12 @@ class MockStore {
|
|
|
394
394
|
noOverride,
|
|
395
395
|
});
|
|
396
396
|
}
|
|
397
|
+
if (this.store[typeName] === undefined) {
|
|
398
|
+
this.store[typeName] = {};
|
|
399
|
+
}
|
|
400
|
+
if (this.store[typeName][key] === undefined) {
|
|
401
|
+
this.store[typeName][key] = {};
|
|
402
|
+
}
|
|
397
403
|
return makeRef(typeName, key);
|
|
398
404
|
}
|
|
399
405
|
generateFieldValue(typeName, fieldName, onOtherFieldsGenerated) {
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/mock",
|
|
3
|
-
"version": "8.4.1
|
|
3
|
+
"version": "8.4.1",
|
|
4
4
|
"description": "A set of utils for faster development of GraphQL tools",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
7
7
|
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@graphql-tools/schema": "8.2.
|
|
11
|
-
"@graphql-tools/utils": "
|
|
10
|
+
"@graphql-tools/schema": "^8.2.0",
|
|
11
|
+
"@graphql-tools/utils": "^8.2.3",
|
|
12
12
|
"fast-json-stable-stringify": "^2.1.0",
|
|
13
13
|
"tslib": "~2.3.0"
|
|
14
14
|
},
|