@graphql-tools/mock 9.0.0 → 9.0.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 -2
- package/cjs/MockList.js +2 -1
- package/cjs/MockStore.js +31 -16
- package/cjs/addMocksToSchema.js +3 -3
- package/cjs/pagination.js +3 -1
- package/esm/MockList.js +2 -1
- package/esm/MockStore.js +32 -17
- package/esm/addMocksToSchema.js +4 -4
- package/esm/mockServer.js +1 -1
- package/esm/pagination.js +3 -1
- package/package.json +2 -2
- package/typings/MockStore.d.cts +1 -1
- package/typings/MockStore.d.ts +1 -1
- package/typings/addMocksToSchema.d.cts +1 -1
- package/typings/addMocksToSchema.d.ts +1 -1
- package/typings/mockServer.d.cts +1 -1
- package/typings/mockServer.d.ts +1 -1
- package/typings/pagination.d.cts +1 -1
- package/typings/pagination.d.ts +1 -1
- package/typings/types.d.cts +1 -1
- package/typings/types.d.ts +1 -1
- package/typings/utils.d.cts +1 -1
- package/typings/utils.d.ts +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Check API Reference for more information about this package;
|
|
2
2
|
https://www.graphql-tools.com/docs/api/modules/mock_src
|
|
3
3
|
|
|
4
|
-
You can also learn more about Mocking in this chapter;
|
|
5
|
-
https://www.graphql-tools.com/docs/mocking
|
|
4
|
+
You can also learn more about Mocking in this chapter; https://www.graphql-tools.com/docs/mocking
|
package/cjs/MockList.js
CHANGED
|
@@ -5,7 +5,8 @@ exports.deepResolveMockList = exports.MockList = exports.isMockList = void 0;
|
|
|
5
5
|
* @internal
|
|
6
6
|
*/
|
|
7
7
|
function isMockList(obj) {
|
|
8
|
-
if (typeof obj?.len === 'number' ||
|
|
8
|
+
if (typeof obj?.len === 'number' ||
|
|
9
|
+
(Array.isArray(obj?.len) && typeof obj?.len[0] === 'number')) {
|
|
9
10
|
if (typeof obj.wrappedFunction === 'undefined' || typeof obj.wrappedFunction === 'function') {
|
|
10
11
|
return true;
|
|
11
12
|
}
|
package/cjs/MockStore.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createMockStore = exports.MockStore = exports.defaultMocks = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const graphql_1 = require("graphql");
|
|
6
5
|
const fast_json_stable_stringify_1 = tslib_1.__importDefault(require("fast-json-stable-stringify"));
|
|
6
|
+
const graphql_1 = require("graphql");
|
|
7
|
+
const MockList_js_1 = require("./MockList.js");
|
|
7
8
|
const types_js_1 = require("./types.js");
|
|
8
9
|
const utils_js_1 = require("./utils.js");
|
|
9
|
-
const MockList_js_1 = require("./MockList.js");
|
|
10
10
|
exports.defaultMocks = {
|
|
11
11
|
Int: () => Math.round(Math.random() * 200) - 100,
|
|
12
12
|
Float: () => Math.random() * 200 - 100,
|
|
@@ -143,11 +143,17 @@ class MockStore {
|
|
|
143
143
|
value = key;
|
|
144
144
|
}
|
|
145
145
|
else {
|
|
146
|
-
value = this.generateFieldValue(typeName, fieldName, (otherFieldName, otherValue) => {
|
|
146
|
+
value = this.generateFieldValue(typeName, fieldName, fieldArgs, (otherFieldName, otherValue) => {
|
|
147
147
|
// if we get a key field in the mix we don't care
|
|
148
148
|
if (this.isKeyField(typeName, otherFieldName))
|
|
149
149
|
return;
|
|
150
|
-
this.set({
|
|
150
|
+
this.set({
|
|
151
|
+
typeName,
|
|
152
|
+
key,
|
|
153
|
+
fieldName: otherFieldName,
|
|
154
|
+
value: otherValue,
|
|
155
|
+
noOverride: true,
|
|
156
|
+
});
|
|
151
157
|
});
|
|
152
158
|
}
|
|
153
159
|
this.set({ typeName, key, fieldName, fieldArgs, value, noOverride: true });
|
|
@@ -239,7 +245,9 @@ class MockStore {
|
|
|
239
245
|
if (!Array.isArray(value))
|
|
240
246
|
throw new Error(`should be an array or null or undefined. Received ${value}`);
|
|
241
247
|
return value.map((v, index) => {
|
|
242
|
-
return this.normalizeValueToStore(nullableFieldType.ofType, v, typeof currentValue === 'object' && currentValue != null && currentValue[index]
|
|
248
|
+
return this.normalizeValueToStore(nullableFieldType.ofType, v, typeof currentValue === 'object' && currentValue != null && currentValue[index]
|
|
249
|
+
? currentValue
|
|
250
|
+
: undefined, onInsertType);
|
|
243
251
|
});
|
|
244
252
|
}
|
|
245
253
|
return value;
|
|
@@ -285,14 +293,14 @@ class MockStore {
|
|
|
285
293
|
}
|
|
286
294
|
return (0, utils_js_1.makeRef)(typeName, key);
|
|
287
295
|
}
|
|
288
|
-
generateFieldValue(typeName, fieldName, onOtherFieldsGenerated) {
|
|
289
|
-
const mockedValue = this.generateFieldValueFromMocks(typeName, fieldName, onOtherFieldsGenerated);
|
|
296
|
+
generateFieldValue(typeName, fieldName, fieldArgs, onOtherFieldsGenerated) {
|
|
297
|
+
const mockedValue = this.generateFieldValueFromMocks(typeName, fieldName, fieldArgs, onOtherFieldsGenerated);
|
|
290
298
|
if (mockedValue !== undefined)
|
|
291
299
|
return mockedValue;
|
|
292
300
|
const fieldType = this.getFieldType(typeName, fieldName);
|
|
293
301
|
return this.generateValueFromType(fieldType);
|
|
294
302
|
}
|
|
295
|
-
generateFieldValueFromMocks(typeName, fieldName, onOtherFieldsGenerated) {
|
|
303
|
+
generateFieldValueFromMocks(typeName, fieldName, fieldArgs, onOtherFieldsGenerated) {
|
|
296
304
|
let value;
|
|
297
305
|
const mock = this.mocks ? this.mocks[typeName] : undefined;
|
|
298
306
|
if (mock) {
|
|
@@ -306,14 +314,17 @@ class MockStore {
|
|
|
306
314
|
continue;
|
|
307
315
|
if (typeof values[otherFieldName] === 'function')
|
|
308
316
|
continue;
|
|
309
|
-
onOtherFieldsGenerated &&
|
|
317
|
+
onOtherFieldsGenerated &&
|
|
318
|
+
onOtherFieldsGenerated(otherFieldName, values[otherFieldName]);
|
|
310
319
|
}
|
|
311
320
|
value = values[fieldName];
|
|
312
321
|
if (typeof value === 'function')
|
|
313
|
-
value = value();
|
|
322
|
+
value = value(fieldArgs);
|
|
314
323
|
}
|
|
315
|
-
else if (typeof mock === 'object' &&
|
|
316
|
-
|
|
324
|
+
else if (typeof mock === 'object' &&
|
|
325
|
+
mock != null &&
|
|
326
|
+
typeof mock[fieldName] === 'function') {
|
|
327
|
+
value = mock[fieldName](fieldArgs);
|
|
317
328
|
}
|
|
318
329
|
}
|
|
319
330
|
if (value !== undefined)
|
|
@@ -325,7 +336,7 @@ class MockStore {
|
|
|
325
336
|
for (const interface_ of interfaces) {
|
|
326
337
|
if (value)
|
|
327
338
|
break;
|
|
328
|
-
value = this.generateFieldValueFromMocks(interface_.name, fieldName, onOtherFieldsGenerated);
|
|
339
|
+
value = this.generateFieldValueFromMocks(interface_.name, fieldName, fieldArgs, onOtherFieldsGenerated);
|
|
329
340
|
}
|
|
330
341
|
}
|
|
331
342
|
return value;
|
|
@@ -334,7 +345,7 @@ class MockStore {
|
|
|
334
345
|
const keyFieldName = this.getKeyFieldName(typeName);
|
|
335
346
|
if (!keyFieldName)
|
|
336
347
|
return (0, utils_js_1.uuidv4)();
|
|
337
|
-
return this.generateFieldValue(typeName, keyFieldName, onOtherFieldsGenerated);
|
|
348
|
+
return this.generateFieldValue(typeName, keyFieldName, undefined, onOtherFieldsGenerated);
|
|
338
349
|
}
|
|
339
350
|
generateValueFromType(fieldType) {
|
|
340
351
|
const nullableType = (0, graphql_1.getNullableType)(fieldType);
|
|
@@ -378,7 +389,9 @@ class MockStore {
|
|
|
378
389
|
}
|
|
379
390
|
typeName = values['__typename'];
|
|
380
391
|
}
|
|
381
|
-
else if (typeof mock === 'object' &&
|
|
392
|
+
else if (typeof mock === 'object' &&
|
|
393
|
+
mock != null &&
|
|
394
|
+
typeof mock['__typename'] === 'function') {
|
|
382
395
|
const mockRes = mock['__typename']();
|
|
383
396
|
if (typeof mockRes !== 'string')
|
|
384
397
|
throw new Error(`'__typename' returned by the mock for abstract type ${nullableType.name} is not a string`);
|
|
@@ -455,7 +468,9 @@ function assertIsDefined(value, message) {
|
|
|
455
468
|
if (value !== undefined && value !== null) {
|
|
456
469
|
return;
|
|
457
470
|
}
|
|
458
|
-
throw new Error(process.env['NODE_ENV'] === 'production'
|
|
471
|
+
throw new Error(process.env['NODE_ENV'] === 'production'
|
|
472
|
+
? 'Invariant failed:'
|
|
473
|
+
: `Invariant failed: ${message || ''}`);
|
|
459
474
|
}
|
|
460
475
|
/**
|
|
461
476
|
* Will create `MockStore` for the given `schema`.
|
package/cjs/addMocksToSchema.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addMocksToSchema = void 0;
|
|
4
4
|
const graphql_1 = require("graphql");
|
|
5
|
-
const utils_1 = require("@graphql-tools/utils");
|
|
6
5
|
const schema_1 = require("@graphql-tools/schema");
|
|
6
|
+
const utils_1 = require("@graphql-tools/utils");
|
|
7
|
+
const MockStore_js_1 = require("./MockStore.js");
|
|
7
8
|
const types_js_1 = require("./types.js");
|
|
8
9
|
const utils_js_1 = require("./utils.js");
|
|
9
|
-
const MockStore_js_1 = require("./MockStore.js");
|
|
10
10
|
// todo: add option to preserve resolver
|
|
11
11
|
/**
|
|
12
12
|
* Given a `schema` and a `MockStore`, returns an executable schema that
|
|
@@ -110,7 +110,7 @@ function addMocksToSchema({ schema, store: maybeStore, mocks, typePolicies, reso
|
|
|
110
110
|
}
|
|
111
111
|
if (defaultResolvedValue === undefined) {
|
|
112
112
|
// any is used here because generateFieldValue is a private method at time of writing
|
|
113
|
-
return store.generateFieldValue(info.parentType.name, info.fieldName);
|
|
113
|
+
return store.generateFieldValue(info.parentType.name, info.fieldName, args);
|
|
114
114
|
}
|
|
115
115
|
return undefined;
|
|
116
116
|
};
|
package/cjs/pagination.js
CHANGED
|
@@ -19,7 +19,9 @@ const utils_js_1 = require("./utils.js");
|
|
|
19
19
|
*/
|
|
20
20
|
const relayStylePaginationMock = (store, { cursorFn = node => `${node.$ref.key}`, applyOnNodes, allNodesFn, } = {}) => {
|
|
21
21
|
return (parent, args, context, info) => {
|
|
22
|
-
const source = (0, utils_js_1.isRootType)(info.parentType, info.schema)
|
|
22
|
+
const source = (0, utils_js_1.isRootType)(info.parentType, info.schema)
|
|
23
|
+
? (0, utils_js_1.makeRef)(info.parentType.name, 'ROOT')
|
|
24
|
+
: parent;
|
|
23
25
|
const allNodesFn_ = allNodesFn ?? defaultAllNodesFn(store);
|
|
24
26
|
let allNodes = allNodesFn_(source, args, context, info);
|
|
25
27
|
if (applyOnNodes) {
|
package/esm/MockList.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* @internal
|
|
3
3
|
*/
|
|
4
4
|
export function isMockList(obj) {
|
|
5
|
-
if (typeof obj?.len === 'number' ||
|
|
5
|
+
if (typeof obj?.len === 'number' ||
|
|
6
|
+
(Array.isArray(obj?.len) && typeof obj?.len[0] === 'number')) {
|
|
6
7
|
if (typeof obj.wrappedFunction === 'undefined' || typeof obj.wrappedFunction === 'function') {
|
|
7
8
|
return true;
|
|
8
9
|
}
|
package/esm/MockStore.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { GraphQLString, isObjectType, isScalarType, getNullableType, isListType, isEnumType, isAbstractType, isCompositeType, isNullableType, isInterfaceType, } from 'graphql';
|
|
2
1
|
import stringify from 'fast-json-stable-stringify';
|
|
3
|
-
import {
|
|
4
|
-
import { uuidv4, randomListLength, takeRandom, makeRef } from './utils.js';
|
|
2
|
+
import { getNullableType, GraphQLString, isAbstractType, isCompositeType, isEnumType, isInterfaceType, isListType, isNullableType, isObjectType, isScalarType, } from 'graphql';
|
|
5
3
|
import { deepResolveMockList, isMockList } from './MockList.js';
|
|
4
|
+
import { assertIsRef, isRecord, isRef, } from './types.js';
|
|
5
|
+
import { makeRef, randomListLength, takeRandom, uuidv4 } from './utils.js';
|
|
6
6
|
export const defaultMocks = {
|
|
7
7
|
Int: () => Math.round(Math.random() * 200) - 100,
|
|
8
8
|
Float: () => Math.random() * 200 - 100,
|
|
@@ -139,11 +139,17 @@ export class MockStore {
|
|
|
139
139
|
value = key;
|
|
140
140
|
}
|
|
141
141
|
else {
|
|
142
|
-
value = this.generateFieldValue(typeName, fieldName, (otherFieldName, otherValue) => {
|
|
142
|
+
value = this.generateFieldValue(typeName, fieldName, fieldArgs, (otherFieldName, otherValue) => {
|
|
143
143
|
// if we get a key field in the mix we don't care
|
|
144
144
|
if (this.isKeyField(typeName, otherFieldName))
|
|
145
145
|
return;
|
|
146
|
-
this.set({
|
|
146
|
+
this.set({
|
|
147
|
+
typeName,
|
|
148
|
+
key,
|
|
149
|
+
fieldName: otherFieldName,
|
|
150
|
+
value: otherValue,
|
|
151
|
+
noOverride: true,
|
|
152
|
+
});
|
|
147
153
|
});
|
|
148
154
|
}
|
|
149
155
|
this.set({ typeName, key, fieldName, fieldArgs, value, noOverride: true });
|
|
@@ -235,7 +241,9 @@ export class MockStore {
|
|
|
235
241
|
if (!Array.isArray(value))
|
|
236
242
|
throw new Error(`should be an array or null or undefined. Received ${value}`);
|
|
237
243
|
return value.map((v, index) => {
|
|
238
|
-
return this.normalizeValueToStore(nullableFieldType.ofType, v, typeof currentValue === 'object' && currentValue != null && currentValue[index]
|
|
244
|
+
return this.normalizeValueToStore(nullableFieldType.ofType, v, typeof currentValue === 'object' && currentValue != null && currentValue[index]
|
|
245
|
+
? currentValue
|
|
246
|
+
: undefined, onInsertType);
|
|
239
247
|
});
|
|
240
248
|
}
|
|
241
249
|
return value;
|
|
@@ -281,14 +289,14 @@ export class MockStore {
|
|
|
281
289
|
}
|
|
282
290
|
return makeRef(typeName, key);
|
|
283
291
|
}
|
|
284
|
-
generateFieldValue(typeName, fieldName, onOtherFieldsGenerated) {
|
|
285
|
-
const mockedValue = this.generateFieldValueFromMocks(typeName, fieldName, onOtherFieldsGenerated);
|
|
292
|
+
generateFieldValue(typeName, fieldName, fieldArgs, onOtherFieldsGenerated) {
|
|
293
|
+
const mockedValue = this.generateFieldValueFromMocks(typeName, fieldName, fieldArgs, onOtherFieldsGenerated);
|
|
286
294
|
if (mockedValue !== undefined)
|
|
287
295
|
return mockedValue;
|
|
288
296
|
const fieldType = this.getFieldType(typeName, fieldName);
|
|
289
297
|
return this.generateValueFromType(fieldType);
|
|
290
298
|
}
|
|
291
|
-
generateFieldValueFromMocks(typeName, fieldName, onOtherFieldsGenerated) {
|
|
299
|
+
generateFieldValueFromMocks(typeName, fieldName, fieldArgs, onOtherFieldsGenerated) {
|
|
292
300
|
let value;
|
|
293
301
|
const mock = this.mocks ? this.mocks[typeName] : undefined;
|
|
294
302
|
if (mock) {
|
|
@@ -302,14 +310,17 @@ export class MockStore {
|
|
|
302
310
|
continue;
|
|
303
311
|
if (typeof values[otherFieldName] === 'function')
|
|
304
312
|
continue;
|
|
305
|
-
onOtherFieldsGenerated &&
|
|
313
|
+
onOtherFieldsGenerated &&
|
|
314
|
+
onOtherFieldsGenerated(otherFieldName, values[otherFieldName]);
|
|
306
315
|
}
|
|
307
316
|
value = values[fieldName];
|
|
308
317
|
if (typeof value === 'function')
|
|
309
|
-
value = value();
|
|
318
|
+
value = value(fieldArgs);
|
|
310
319
|
}
|
|
311
|
-
else if (typeof mock === 'object' &&
|
|
312
|
-
|
|
320
|
+
else if (typeof mock === 'object' &&
|
|
321
|
+
mock != null &&
|
|
322
|
+
typeof mock[fieldName] === 'function') {
|
|
323
|
+
value = mock[fieldName](fieldArgs);
|
|
313
324
|
}
|
|
314
325
|
}
|
|
315
326
|
if (value !== undefined)
|
|
@@ -321,7 +332,7 @@ export class MockStore {
|
|
|
321
332
|
for (const interface_ of interfaces) {
|
|
322
333
|
if (value)
|
|
323
334
|
break;
|
|
324
|
-
value = this.generateFieldValueFromMocks(interface_.name, fieldName, onOtherFieldsGenerated);
|
|
335
|
+
value = this.generateFieldValueFromMocks(interface_.name, fieldName, fieldArgs, onOtherFieldsGenerated);
|
|
325
336
|
}
|
|
326
337
|
}
|
|
327
338
|
return value;
|
|
@@ -330,7 +341,7 @@ export class MockStore {
|
|
|
330
341
|
const keyFieldName = this.getKeyFieldName(typeName);
|
|
331
342
|
if (!keyFieldName)
|
|
332
343
|
return uuidv4();
|
|
333
|
-
return this.generateFieldValue(typeName, keyFieldName, onOtherFieldsGenerated);
|
|
344
|
+
return this.generateFieldValue(typeName, keyFieldName, undefined, onOtherFieldsGenerated);
|
|
334
345
|
}
|
|
335
346
|
generateValueFromType(fieldType) {
|
|
336
347
|
const nullableType = getNullableType(fieldType);
|
|
@@ -374,7 +385,9 @@ export class MockStore {
|
|
|
374
385
|
}
|
|
375
386
|
typeName = values['__typename'];
|
|
376
387
|
}
|
|
377
|
-
else if (typeof mock === 'object' &&
|
|
388
|
+
else if (typeof mock === 'object' &&
|
|
389
|
+
mock != null &&
|
|
390
|
+
typeof mock['__typename'] === 'function') {
|
|
378
391
|
const mockRes = mock['__typename']();
|
|
379
392
|
if (typeof mockRes !== 'string')
|
|
380
393
|
throw new Error(`'__typename' returned by the mock for abstract type ${nullableType.name} is not a string`);
|
|
@@ -450,7 +463,9 @@ function assertIsDefined(value, message) {
|
|
|
450
463
|
if (value !== undefined && value !== null) {
|
|
451
464
|
return;
|
|
452
465
|
}
|
|
453
|
-
throw new Error(process.env['NODE_ENV'] === 'production'
|
|
466
|
+
throw new Error(process.env['NODE_ENV'] === 'production'
|
|
467
|
+
? 'Invariant failed:'
|
|
468
|
+
: `Invariant failed: ${message || ''}`);
|
|
454
469
|
}
|
|
455
470
|
/**
|
|
456
471
|
* Will create `MockStore` for the given `schema`.
|
package/esm/addMocksToSchema.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { defaultFieldResolver,
|
|
2
|
-
import { mapSchema, MapperKind } from '@graphql-tools/utils';
|
|
1
|
+
import { defaultFieldResolver, GraphQLInterfaceType, GraphQLUnionType, isSchema, isUnionType, } from 'graphql';
|
|
3
2
|
import { addResolversToSchema } from '@graphql-tools/schema';
|
|
3
|
+
import { MapperKind, mapSchema } from '@graphql-tools/utils';
|
|
4
|
+
import { createMockStore } from './MockStore.js';
|
|
4
5
|
import { isRef } from './types.js';
|
|
5
6
|
import { copyOwnProps, isObject, isRootType } from './utils.js';
|
|
6
|
-
import { createMockStore } from './MockStore.js';
|
|
7
7
|
// todo: add option to preserve resolver
|
|
8
8
|
/**
|
|
9
9
|
* Given a `schema` and a `MockStore`, returns an executable schema that
|
|
@@ -107,7 +107,7 @@ export function addMocksToSchema({ schema, store: maybeStore, mocks, typePolicie
|
|
|
107
107
|
}
|
|
108
108
|
if (defaultResolvedValue === undefined) {
|
|
109
109
|
// any is used here because generateFieldValue is a private method at time of writing
|
|
110
|
-
return store.generateFieldValue(info.parentType.name, info.fieldName);
|
|
110
|
+
return store.generateFieldValue(info.parentType.name, info.fieldName, args);
|
|
111
111
|
}
|
|
112
112
|
return undefined;
|
|
113
113
|
};
|
package/esm/mockServer.js
CHANGED
package/esm/pagination.js
CHANGED
|
@@ -16,7 +16,9 @@ import { isRootType, makeRef } from './utils.js';
|
|
|
16
16
|
*/
|
|
17
17
|
export const relayStylePaginationMock = (store, { cursorFn = node => `${node.$ref.key}`, applyOnNodes, allNodesFn, } = {}) => {
|
|
18
18
|
return (parent, args, context, info) => {
|
|
19
|
-
const source = isRootType(info.parentType, info.schema)
|
|
19
|
+
const source = isRootType(info.parentType, info.schema)
|
|
20
|
+
? makeRef(info.parentType.name, 'ROOT')
|
|
21
|
+
: parent;
|
|
20
22
|
const allNodesFn_ = allNodesFn ?? defaultAllNodesFn(store);
|
|
21
23
|
let allNodes = allNodesFn_(source, args, context, info);
|
|
22
24
|
if (applyOnNodes) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/mock",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.1",
|
|
4
4
|
"description": "A set of utils for faster development of GraphQL tools",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@graphql-tools/schema": "^10.0.0",
|
|
11
|
-
"@graphql-tools/utils": "^10.0.
|
|
11
|
+
"@graphql-tools/utils": "^10.0.13",
|
|
12
12
|
"fast-json-stable-stringify": "^2.1.0",
|
|
13
13
|
"tslib": "^2.4.0"
|
|
14
14
|
},
|
package/typings/MockStore.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GraphQLSchema } from 'graphql';
|
|
2
|
-
import {
|
|
2
|
+
import { GetArgs, IMocks, IMockStore, KeyTypeConstraints, Ref, SetArgs, TypePolicy } from './types.cjs';
|
|
3
3
|
export declare const defaultMocks: {
|
|
4
4
|
Int: () => number;
|
|
5
5
|
Float: () => number;
|
package/typings/MockStore.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GraphQLSchema } from 'graphql';
|
|
2
|
-
import {
|
|
2
|
+
import { GetArgs, IMocks, IMockStore, KeyTypeConstraints, Ref, SetArgs, TypePolicy } from './types.js';
|
|
3
3
|
export declare const defaultMocks: {
|
|
4
4
|
Int: () => number;
|
|
5
5
|
Float: () => number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GraphQLSchema } from 'graphql';
|
|
2
2
|
import { IResolvers } from '@graphql-tools/utils';
|
|
3
|
-
import {
|
|
3
|
+
import { IMocks, IMockStore, TypePolicy } from './types.cjs';
|
|
4
4
|
type IMockOptions<TResolvers = IResolvers> = {
|
|
5
5
|
schema: GraphQLSchema;
|
|
6
6
|
store?: IMockStore;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GraphQLSchema } from 'graphql';
|
|
2
2
|
import { IResolvers } from '@graphql-tools/utils';
|
|
3
|
-
import {
|
|
3
|
+
import { IMocks, IMockStore, TypePolicy } from './types.js';
|
|
4
4
|
type IMockOptions<TResolvers = IResolvers> = {
|
|
5
5
|
schema: GraphQLSchema;
|
|
6
6
|
store?: IMockStore;
|
package/typings/mockServer.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TypeSource } from '@graphql-tools/utils';
|
|
2
|
-
import {
|
|
2
|
+
import { IMocks, IMockServer } from './types.cjs';
|
|
3
3
|
/**
|
|
4
4
|
* A convenience wrapper on top of addMocksToSchema. It adds your mock resolvers
|
|
5
5
|
* to your schema and returns a client that will correctly execute your query with
|
package/typings/mockServer.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TypeSource } from '@graphql-tools/utils';
|
|
2
|
-
import {
|
|
2
|
+
import { IMocks, IMockServer } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* A convenience wrapper on top of addMocksToSchema. It adds your mock resolvers
|
|
5
5
|
* to your schema and returns a client that will correctly execute your query with
|
package/typings/pagination.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IFieldResolver } from '@graphql-tools/utils';
|
|
2
1
|
import { GraphQLResolveInfo } from 'graphql';
|
|
2
|
+
import { IFieldResolver } from '@graphql-tools/utils';
|
|
3
3
|
import { IMockStore, Ref } from './types.cjs';
|
|
4
4
|
export type AllNodesFn<TContext, TArgs extends RelayPaginationParams> = (parent: Ref, args: TArgs, context: TContext, info: GraphQLResolveInfo) => Ref[];
|
|
5
5
|
export type RelayStylePaginationMockOptions<TContext, TArgs extends RelayPaginationParams> = {
|
package/typings/pagination.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IFieldResolver } from '@graphql-tools/utils';
|
|
2
1
|
import { GraphQLResolveInfo } from 'graphql';
|
|
2
|
+
import { IFieldResolver } from '@graphql-tools/utils';
|
|
3
3
|
import { IMockStore, Ref } from './types.js';
|
|
4
4
|
export type AllNodesFn<TContext, TArgs extends RelayPaginationParams> = (parent: Ref, args: TArgs, context: TContext, info: GraphQLResolveInfo) => Ref[];
|
|
5
5
|
export type RelayStylePaginationMockOptions<TContext, TArgs extends RelayPaginationParams> = {
|
package/typings/types.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ExecutionResult, IResolvers } from '@graphql-tools/utils';
|
|
2
1
|
import { GraphQLSchema } from 'graphql';
|
|
2
|
+
import { ExecutionResult, IResolvers } from '@graphql-tools/utils';
|
|
3
3
|
export type IMockFn = () => unknown;
|
|
4
4
|
export type IScalarMock = unknown | IMockFn;
|
|
5
5
|
export type ITypeMock = () => {
|
package/typings/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ExecutionResult, IResolvers } from '@graphql-tools/utils';
|
|
2
1
|
import { GraphQLSchema } from 'graphql';
|
|
2
|
+
import { ExecutionResult, IResolvers } from '@graphql-tools/utils';
|
|
3
3
|
export type IMockFn = () => unknown;
|
|
4
4
|
export type IScalarMock = unknown | IMockFn;
|
|
5
5
|
export type ITypeMock = () => {
|
package/typings/utils.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GraphQLObjectType, GraphQLSchema } from 'graphql';
|
|
2
|
-
import {
|
|
2
|
+
import { KeyTypeConstraints, Ref } from './types.cjs';
|
|
3
3
|
export declare function uuidv4(): string;
|
|
4
4
|
export declare const randomListLength: () => number;
|
|
5
5
|
export declare const takeRandom: <T>(arr: T[]) => T;
|
package/typings/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GraphQLObjectType, GraphQLSchema } from 'graphql';
|
|
2
|
-
import {
|
|
2
|
+
import { KeyTypeConstraints, Ref } from './types.js';
|
|
3
3
|
export declare function uuidv4(): string;
|
|
4
4
|
export declare const randomListLength: () => number;
|
|
5
5
|
export declare const takeRandom: <T>(arr: T[]) => T;
|