@apollo/client 3.10.0-alpha.1 → 3.10.0-rc.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/.changeset/chatty-llamas-switch.md +5 -0
- package/.changeset/cold-dancers-call.md +5 -0
- package/.changeset/green-garlics-protect.md +5 -0
- package/.changeset/hungry-bobcats-battle.md +5 -0
- package/.changeset/kind-foxes-float.md +5 -0
- package/.changeset/old-onions-sleep.md +5 -0
- package/.changeset/pre.json +14 -3
- package/.changeset/spotty-garlics-knock.md +5 -0
- package/.changeset/strong-paws-kneel.md +5 -0
- package/.changeset/stupid-bears-cheat.md +5 -0
- package/.changeset/tiny-bugs-tap.md +5 -0
- package/.changeset/twelve-apples-vanish.md +5 -0
- package/.changeset/wet-plants-admire.md +5 -0
- package/CHANGELOG.md +64 -2
- package/apollo-client.cjs +70 -19
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +8 -6
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +8 -6
- package/cache/index.d.ts +1 -1
- package/cache/index.js.map +1 -1
- package/cache/inmemory/readFromStore.js +8 -6
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/core/ApolloClient.js +1 -0
- package/core/ApolloClient.js.map +1 -1
- package/core/core.cjs +2 -1
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +2 -1
- package/core/index.d.ts +1 -1
- package/core/index.js.map +1 -1
- package/dev/dev.cjs +18 -15
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +18 -15
- package/dev/index.d.ts +2 -0
- package/dev/index.js +1 -0
- package/dev/index.js.map +1 -1
- package/dev/loadErrorMessageHandler.d.ts +6 -1
- package/dev/loadErrorMessageHandler.js +17 -14
- package/dev/loadErrorMessageHandler.js.map +1 -1
- package/dev/setErrorMessageHandler.d.ts +34 -0
- package/dev/setErrorMessageHandler.js +9 -0
- package/dev/setErrorMessageHandler.js.map +1 -0
- package/package.json +18 -16
- package/react/hooks/hooks.cjs +28 -2
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +28 -2
- package/react/hooks/internal/wrapHook.d.ts +2 -1
- package/react/hooks/internal/wrapHook.js.map +1 -1
- package/react/hooks/useBackgroundQuery.js +14 -0
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useQueryRefHandlers.js +12 -0
- package/react/hooks/useQueryRefHandlers.js.map +1 -1
- package/react/hooks/useReadQuery.js +19 -2
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks/useSuspenseQuery.js +27 -0
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/internal/cache/QueryReference.d.ts +3 -1
- package/react/internal/cache/QueryReference.js +39 -11
- package/react/internal/cache/QueryReference.js.map +1 -1
- package/react/internal/cache/SuspenseCache.d.ts +1 -0
- package/react/internal/cache/SuspenseCache.js +4 -0
- package/react/internal/cache/SuspenseCache.js.map +1 -1
- package/react/internal/internal.cjs +32 -10
- package/react/internal/internal.cjs.map +1 -1
- package/react/internal/internal.cjs.native.js +32 -10
- package/react/query-preloader/createQueryPreloader.d.ts +0 -1
- package/react/query-preloader/createQueryPreloader.js +0 -1
- package/react/query-preloader/createQueryPreloader.js.map +1 -1
- package/react/react.cjs.map +1 -1
- package/testing/experimental/createSchemaFetch.d.ts +43 -0
- package/testing/experimental/createSchemaFetch.js +99 -0
- package/testing/experimental/createSchemaFetch.js.map +1 -0
- package/testing/experimental/createTestSchema.d.ts +55 -0
- package/testing/experimental/createTestSchema.js +110 -0
- package/testing/experimental/createTestSchema.js.map +1 -0
- package/testing/experimental/experimental.cjs +274 -0
- package/testing/experimental/experimental.cjs.map +1 -0
- package/testing/experimental/experimental.cjs.native.js +274 -0
- package/testing/experimental/graphql-tools/utils.d.ts +26 -0
- package/testing/experimental/graphql-tools/utils.js +172 -0
- package/testing/experimental/graphql-tools/utils.js.map +1 -0
- package/testing/experimental/graphql-tools/utils.test.d.ts +2 -0
- package/testing/experimental/graphql-tools/utils.test.js +139 -0
- package/testing/experimental/graphql-tools/utils.test.js.map +1 -0
- package/testing/experimental/index.d.ts +3 -0
- package/testing/experimental/index.js +3 -0
- package/testing/experimental/index.js.map +1 -0
- package/testing/experimental/package.json +8 -0
- package/testing/internal/profile/profile.js +6 -2
- package/testing/internal/profile/profile.js.map +1 -1
- package/utilities/globals/globals.cjs +1 -1
- package/utilities/globals/globals.cjs.map +1 -1
- package/utilities/globals/globals.cjs.native.js +1 -1
- package/utilities/globals/invariantWrappers.d.ts +1 -1
- package/utilities/globals/invariantWrappers.js.map +1 -1
- package/version.js +1 -1
- package/.changeset/flat-singers-kiss.md +0 -5
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { __awaiter, __generator } from "tslib";
|
|
2
|
+
import { execute, validate } from "graphql";
|
|
3
|
+
import { ApolloError, gql } from "../../core/index.js";
|
|
4
|
+
import { withCleanup } from "../internal/index.js";
|
|
5
|
+
import { wait } from "../core/wait.js";
|
|
6
|
+
/**
|
|
7
|
+
* A function that accepts a static `schema` and a `mockFetchOpts` object and
|
|
8
|
+
* returns a disposable object with `mock` and `restore` functions.
|
|
9
|
+
*
|
|
10
|
+
* The `mock` function is a mock fetch function that is set on the global
|
|
11
|
+
* `window` object. This function intercepts any fetch requests and
|
|
12
|
+
* returns a response by executing the operation against the provided schema.
|
|
13
|
+
*
|
|
14
|
+
* The `restore` function is a cleanup function that will restore the previous
|
|
15
|
+
* `fetch`. It is automatically called if the function's return value is
|
|
16
|
+
* declared with `using`. If your environment does not support the language
|
|
17
|
+
* feature `using`, you should manually invoke the `restore` function.
|
|
18
|
+
*
|
|
19
|
+
* @param schema - A `GraphQLSchema`.
|
|
20
|
+
* @param mockFetchOpts - Configuration options.
|
|
21
|
+
* @returns An object with both `mock` and `restore` functions.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```js
|
|
25
|
+
* using _fetch = createSchemaFetch(schema); // automatically restores fetch after exiting the block
|
|
26
|
+
*
|
|
27
|
+
* const { restore } = createSchemaFetch(schema);
|
|
28
|
+
* restore(); // manually restore fetch if `using` is not supported
|
|
29
|
+
* ```
|
|
30
|
+
* @since 3.10.0
|
|
31
|
+
* @alpha
|
|
32
|
+
*/
|
|
33
|
+
var createSchemaFetch = function (schema, mockFetchOpts) {
|
|
34
|
+
var _a, _b, _c, _d;
|
|
35
|
+
if (mockFetchOpts === void 0) { mockFetchOpts = { validate: true }; }
|
|
36
|
+
var prevFetch = window.fetch;
|
|
37
|
+
var delayMin = (_b = (_a = mockFetchOpts.delay) === null || _a === void 0 ? void 0 : _a.min) !== null && _b !== void 0 ? _b : 3;
|
|
38
|
+
var delayMax = (_d = (_c = mockFetchOpts.delay) === null || _c === void 0 ? void 0 : _c.max) !== null && _d !== void 0 ? _d : delayMin + 2;
|
|
39
|
+
if (delayMin > delayMax) {
|
|
40
|
+
throw new Error("Please configure a minimum delay that is less than the maximum delay. The default minimum delay is 3ms.");
|
|
41
|
+
}
|
|
42
|
+
var mockFetch = function (_uri, options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
43
|
+
var randomDelay, body, document, validationErrors, result, stringifiedResult;
|
|
44
|
+
return __generator(this, function (_a) {
|
|
45
|
+
switch (_a.label) {
|
|
46
|
+
case 0:
|
|
47
|
+
if (!(delayMin > 0)) return [3 /*break*/, 2];
|
|
48
|
+
randomDelay = Math.random() * (delayMax - delayMin) + delayMin;
|
|
49
|
+
return [4 /*yield*/, wait(randomDelay)];
|
|
50
|
+
case 1:
|
|
51
|
+
_a.sent();
|
|
52
|
+
_a.label = 2;
|
|
53
|
+
case 2:
|
|
54
|
+
body = JSON.parse(options.body);
|
|
55
|
+
document = gql(body.query);
|
|
56
|
+
if (mockFetchOpts.validate) {
|
|
57
|
+
validationErrors = [];
|
|
58
|
+
try {
|
|
59
|
+
validationErrors = validate(schema, document);
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
validationErrors = [
|
|
63
|
+
new ApolloError({ graphQLErrors: [e] }),
|
|
64
|
+
];
|
|
65
|
+
}
|
|
66
|
+
if ((validationErrors === null || validationErrors === void 0 ? void 0 : validationErrors.length) > 0) {
|
|
67
|
+
return [2 /*return*/, new Response(JSON.stringify({ errors: validationErrors }))];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return [4 /*yield*/, execute({
|
|
71
|
+
schema: schema,
|
|
72
|
+
document: document,
|
|
73
|
+
variableValues: body.variables,
|
|
74
|
+
operationName: body.operationName,
|
|
75
|
+
})];
|
|
76
|
+
case 3:
|
|
77
|
+
result = _a.sent();
|
|
78
|
+
stringifiedResult = JSON.stringify(result);
|
|
79
|
+
return [2 /*return*/, new Response(stringifiedResult)];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}); };
|
|
83
|
+
function mockGlobal() {
|
|
84
|
+
window.fetch = mockFetch;
|
|
85
|
+
var restore = function () {
|
|
86
|
+
if (window.fetch === mockFetch) {
|
|
87
|
+
window.fetch = prevFetch;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
return withCleanup({ restore: restore }, restore);
|
|
91
|
+
}
|
|
92
|
+
return Object.assign(mockFetch, {
|
|
93
|
+
mockGlobal: mockGlobal,
|
|
94
|
+
// if https://github.com/rbuckton/proposal-using-enforcement lands
|
|
95
|
+
// [Symbol.enter]: mockGlobal
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
export { createSchemaFetch };
|
|
99
|
+
//# sourceMappingURL=createSchemaFetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createSchemaFetch.js","sourceRoot":"","sources":["../../../src/testing/experimental/createSchemaFetch.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,WAAW,E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WAAW,CAAC,EAAE,aAAa,EAAE,CAAC,CAAiB,CAAC,EAAE,CAAC;6BACxD,CAAC;wBACJ,CAAC;wBAED,IAAI,CAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,MAAM,IAAG,CAAC,EAAE,CAAC;4BACjC,sBAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC,CAAC,EAAC;wBACpE,CAAC;oBACH,CAAC;oBAEc,qBAAM,OAAO,CAAC;4BAC3B,MAAM,QAAA;4BACN,QAAQ,UAAA;4BACR,cAAc,EAAE,IAAI,CAAC,SAAS;4BAC9B,aAAa,EAAE,IAAI,CAAC,aAAa;yBAClC,CAAC,EAAA;;oBALI,MAAM,GAAG,SAKb;oBAEI,iBAAiB,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;oBAEjD,sBAAO,IAAI,QAAQ,CAAC,iBAAiB,CAAC,EAAC;;;SACxC,CAAC;IAEF,SAAS,UAAU;QACjB,MAAM,CAAC,KAAK,GAAG,SAAS,CAAC;QAEzB,IAAM,OAAO,GAAG;YACd,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;gBAC/B,MAAM,CAAC,KAAK,GAAG,SAAS,CAAC;YAC3B,CAAC;QACH,CAAC,CAAC;QAEF,OAAO,WAAW,CAAC,EAAE,OAAO,SAAA,EAAE,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE;QAC9B,UAAU,YAAA;QACV,kEAAkE;QAClE,6BAA6B;KAC9B,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["import { execute, validate } from \"graphql\";\nimport type { GraphQLError, GraphQLSchema } from \"graphql\";\nimport { ApolloError, gql } from \"../../core/index.js\";\nimport { withCleanup } from \"../internal/index.js\";\nimport { wait } from \"../core/wait.js\";\n\n/**\n * A function that accepts a static `schema` and a `mockFetchOpts` object and\n * returns a disposable object with `mock` and `restore` functions.\n *\n * The `mock` function is a mock fetch function that is set on the global\n * `window` object. This function intercepts any fetch requests and\n * returns a response by executing the operation against the provided schema.\n *\n * The `restore` function is a cleanup function that will restore the previous\n * `fetch`. It is automatically called if the function's return value is\n * declared with `using`. If your environment does not support the language\n * feature `using`, you should manually invoke the `restore` function.\n *\n * @param schema - A `GraphQLSchema`.\n * @param mockFetchOpts - Configuration options.\n * @returns An object with both `mock` and `restore` functions.\n *\n * @example\n * ```js\n * using _fetch = createSchemaFetch(schema); // automatically restores fetch after exiting the block\n *\n * const { restore } = createSchemaFetch(schema);\n * restore(); // manually restore fetch if `using` is not supported\n * ```\n * @since 3.10.0\n * @alpha\n */\nconst createSchemaFetch = (\n schema: GraphQLSchema,\n mockFetchOpts: {\n validate?: boolean;\n delay?: { min: number; max: number };\n } = { validate: true }\n) => {\n const prevFetch = window.fetch;\n const delayMin = mockFetchOpts.delay?.min ?? 3;\n const delayMax = mockFetchOpts.delay?.max ?? delayMin + 2;\n\n if (delayMin > delayMax) {\n throw new Error(\n \"Please configure a minimum delay that is less than the maximum delay. The default minimum delay is 3ms.\"\n );\n }\n\n const mockFetch: (uri?: any, options?: any) => Promise<Response> = async (\n _uri,\n options\n ) => {\n if (delayMin > 0) {\n const randomDelay = Math.random() * (delayMax - delayMin) + delayMin;\n await wait(randomDelay);\n }\n\n const body = JSON.parse(options.body);\n const document = gql(body.query);\n\n if (mockFetchOpts.validate) {\n let validationErrors: readonly Error[] = [];\n\n try {\n validationErrors = validate(schema, document);\n } catch (e) {\n validationErrors = [\n new ApolloError({ graphQLErrors: [e as GraphQLError] }),\n ];\n }\n\n if (validationErrors?.length > 0) {\n return new Response(JSON.stringify({ errors: validationErrors }));\n }\n }\n\n const result = await execute({\n schema,\n document,\n variableValues: body.variables,\n operationName: body.operationName,\n });\n\n const stringifiedResult = JSON.stringify(result);\n\n return new Response(stringifiedResult);\n };\n\n function mockGlobal() {\n window.fetch = mockFetch;\n\n const restore = () => {\n if (window.fetch === mockFetch) {\n window.fetch = prevFetch;\n }\n };\n\n return withCleanup({ restore }, restore);\n }\n\n return Object.assign(mockFetch, {\n mockGlobal,\n // if https://github.com/rbuckton/proposal-using-enforcement lands\n // [Symbol.enter]: mockGlobal\n });\n};\n\nexport { createSchemaFetch };\n"]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { GraphQLSchema } from "graphql";
|
|
2
|
+
import type { Resolvers } from "../../core/types.js";
|
|
3
|
+
type ProxiedSchema = GraphQLSchema & TestSchemaFns;
|
|
4
|
+
interface TestSchemaFns {
|
|
5
|
+
add: (addOptions: {
|
|
6
|
+
resolvers: Resolvers;
|
|
7
|
+
}) => ProxiedSchema;
|
|
8
|
+
fork: (forkOptions?: {
|
|
9
|
+
resolvers?: Resolvers;
|
|
10
|
+
}) => ProxiedSchema;
|
|
11
|
+
reset: () => void;
|
|
12
|
+
}
|
|
13
|
+
interface TestSchemaOptions {
|
|
14
|
+
resolvers: Resolvers;
|
|
15
|
+
scalars?: {
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A function that creates a [Proxy object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy)
|
|
21
|
+
* around a given `schema` with `resolvers`. This proxied schema can be used to
|
|
22
|
+
* progressively layer resolvers on top of the original schema using the `add`
|
|
23
|
+
* method. The `fork` method can be used to create a new proxied schema which
|
|
24
|
+
* can be modified independently of the original schema. `reset` will restore
|
|
25
|
+
* resolvers to the original proxied schema.
|
|
26
|
+
*
|
|
27
|
+
* @param schema - A `GraphQLSchema`.
|
|
28
|
+
* @param options - An `options` object that accepts `scalars` and `resolvers` objects.
|
|
29
|
+
* @returns A `ProxiedSchema` with `add`, `fork` and `reset` methods.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```js
|
|
33
|
+
*
|
|
34
|
+
* const schema = createTestSchema(schemaWithTypeDefs, {
|
|
35
|
+
* resolvers: {
|
|
36
|
+
Query: {
|
|
37
|
+
writer: () => ({
|
|
38
|
+
name: "Ada Lovelace",
|
|
39
|
+
}),
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
scalars: {
|
|
43
|
+
ID: () => "1",
|
|
44
|
+
Int: () => 36,
|
|
45
|
+
String: () => "String",
|
|
46
|
+
Date: () => new Date("December 10, 1815 01:00:00").toJSON().split("T")[0],
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
* ```
|
|
50
|
+
* @since 3.9.0
|
|
51
|
+
* @alpha
|
|
52
|
+
*/
|
|
53
|
+
declare const createTestSchema: (schemaWithTypeDefs: GraphQLSchema, options: TestSchemaOptions) => ProxiedSchema;
|
|
54
|
+
export { createTestSchema };
|
|
55
|
+
//# sourceMappingURL=createTestSchema.d.ts.map
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { addResolversToSchema } from "@graphql-tools/schema";
|
|
3
|
+
import { mergeResolvers } from "@graphql-tools/merge";
|
|
4
|
+
import { createMockSchema } from "./graphql-tools/utils.js";
|
|
5
|
+
/**
|
|
6
|
+
* A function that creates a [Proxy object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy)
|
|
7
|
+
* around a given `schema` with `resolvers`. This proxied schema can be used to
|
|
8
|
+
* progressively layer resolvers on top of the original schema using the `add`
|
|
9
|
+
* method. The `fork` method can be used to create a new proxied schema which
|
|
10
|
+
* can be modified independently of the original schema. `reset` will restore
|
|
11
|
+
* resolvers to the original proxied schema.
|
|
12
|
+
*
|
|
13
|
+
* @param schema - A `GraphQLSchema`.
|
|
14
|
+
* @param options - An `options` object that accepts `scalars` and `resolvers` objects.
|
|
15
|
+
* @returns A `ProxiedSchema` with `add`, `fork` and `reset` methods.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```js
|
|
19
|
+
*
|
|
20
|
+
* const schema = createTestSchema(schemaWithTypeDefs, {
|
|
21
|
+
* resolvers: {
|
|
22
|
+
Query: {
|
|
23
|
+
writer: () => ({
|
|
24
|
+
name: "Ada Lovelace",
|
|
25
|
+
}),
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
scalars: {
|
|
29
|
+
ID: () => "1",
|
|
30
|
+
Int: () => 36,
|
|
31
|
+
String: () => "String",
|
|
32
|
+
Date: () => new Date("December 10, 1815 01:00:00").toJSON().split("T")[0],
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
* ```
|
|
36
|
+
* @since 3.9.0
|
|
37
|
+
* @alpha
|
|
38
|
+
*/
|
|
39
|
+
var createTestSchema = function (schemaWithTypeDefs, options) {
|
|
40
|
+
var _a;
|
|
41
|
+
var targetResolvers = __assign({}, options.resolvers);
|
|
42
|
+
var targetSchema = addResolversToSchema({
|
|
43
|
+
schema: createMockSchema(schemaWithTypeDefs, (_a = options.scalars) !== null && _a !== void 0 ? _a : {}),
|
|
44
|
+
resolvers: targetResolvers,
|
|
45
|
+
});
|
|
46
|
+
var fns = {
|
|
47
|
+
add: function (_a) {
|
|
48
|
+
var newResolvers = _a.resolvers;
|
|
49
|
+
// @ts-ignore TODO(fixme): IResolvers type does not play well with our Resolvers
|
|
50
|
+
targetResolvers = mergeResolvers([targetResolvers, newResolvers]);
|
|
51
|
+
targetSchema = addResolversToSchema({
|
|
52
|
+
schema: targetSchema,
|
|
53
|
+
resolvers: targetResolvers,
|
|
54
|
+
});
|
|
55
|
+
return targetSchema;
|
|
56
|
+
},
|
|
57
|
+
fork: function (_a) {
|
|
58
|
+
var _b;
|
|
59
|
+
var _c = _a === void 0 ? {} : _a, newResolvers = _c.resolvers;
|
|
60
|
+
return createTestSchema(targetSchema, {
|
|
61
|
+
// @ts-ignore TODO(fixme): IResolvers type does not play well with our Resolvers
|
|
62
|
+
resolvers: (_b = mergeResolvers([targetResolvers, newResolvers])) !== null && _b !== void 0 ? _b : targetResolvers,
|
|
63
|
+
scalars: options.scalars,
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
reset: function () {
|
|
67
|
+
targetSchema = addResolversToSchema({
|
|
68
|
+
schema: schemaWithTypeDefs,
|
|
69
|
+
resolvers: options.resolvers,
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
var schema = new Proxy(targetSchema, {
|
|
74
|
+
get: function (_target, p) {
|
|
75
|
+
if (p in fns) {
|
|
76
|
+
return Reflect.get(fns, p);
|
|
77
|
+
}
|
|
78
|
+
// An optimization that eliminates round-trips through the proxy
|
|
79
|
+
// on class methods invoked via `this` on a base class instance wrapped by
|
|
80
|
+
// the proxy.
|
|
81
|
+
//
|
|
82
|
+
// For example, consider the following class:
|
|
83
|
+
//
|
|
84
|
+
// class Base {
|
|
85
|
+
// foo(){
|
|
86
|
+
// this.bar()
|
|
87
|
+
// }
|
|
88
|
+
// bar(){
|
|
89
|
+
// ...
|
|
90
|
+
// }
|
|
91
|
+
// }
|
|
92
|
+
//
|
|
93
|
+
// Calling `proxy.foo()` would call `foo` with `this` being the proxy.
|
|
94
|
+
// This would result in calling `proxy.bar()` which would again invoke
|
|
95
|
+
// the proxy to resolve `bar` and call that method.
|
|
96
|
+
//
|
|
97
|
+
// Instead, calls to `proxy.foo()` should result in a call to
|
|
98
|
+
// `innerObject.foo()` with a `this` of `innerObject`, and that call
|
|
99
|
+
// should directly call `innerObject.bar()`.
|
|
100
|
+
var property = Reflect.get(targetSchema, p);
|
|
101
|
+
if (typeof property === "function") {
|
|
102
|
+
return property.bind(targetSchema);
|
|
103
|
+
}
|
|
104
|
+
return property;
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
return schema;
|
|
108
|
+
};
|
|
109
|
+
export { createTestSchema };
|
|
110
|
+
//# sourceMappingURL=createTestSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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AkB;gBAC1B,SAAS,EAAE,OAAO,CAAC,SAAS;aAC7B,CAAC,CAAC;QACL,CAAC;KACF,CAAC;IAEF,IAAM,MAAM,GAAG,IAAI,KAAK,CAAC,YAAY,EAAE;QACrC,GAAG,YAAC,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;gBACb,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YAC7B,CAAC;YAED,gEAAgE;YAChE,0EAA0E;YAC1E,aAAa;YACb,EAAE;YACF,6CAA6C;YAC7C,EAAE;YACF,eAAe;YACf,WAAW;YACX,iBAAiB;YACjB,MAAM;YACN,WAAW;YACX,UAAU;YACV,MAAM;YACN,IAAI;YACJ,EAAE;YACF,sEAAsE;YACtE,sEAAsE;YACtE,mDAAmD;YACnD,EAAE;YACF,6DAA6D;YAC7D,oEAAoE;YACpE,4CAA4C;YAE5C,IAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;YAC9C,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;gBACnC,OAAO,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YACrC,CAAC;YACD,OAAO,QAAQ,CAAC;QAClB,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,MAAuB,CAAC;AACjC,CAAC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["import type { GraphQLSchema } from \"graphql\";\nimport { addResolversToSchema } from \"@graphql-tools/schema\";\nimport { mergeResolvers } from \"@graphql-tools/merge\";\nimport { createMockSchema } from \"./graphql-tools/utils.js\";\nimport type { Resolvers } from \"../../core/types.js\";\n\ntype ProxiedSchema = GraphQLSchema & TestSchemaFns;\n\ninterface TestSchemaFns {\n add: (addOptions: { resolvers: Resolvers }) => ProxiedSchema;\n fork: (forkOptions?: { resolvers?: Resolvers }) => ProxiedSchema;\n reset: () => void;\n}\n\ninterface TestSchemaOptions {\n resolvers: Resolvers;\n scalars?: { [key: string]: any };\n}\n\n/**\n * A function that creates a [Proxy object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy)\n * around a given `schema` with `resolvers`. This proxied schema can be used to\n * progressively layer resolvers on top of the original schema using the `add`\n * method. The `fork` method can be used to create a new proxied schema which\n * can be modified independently of the original schema. `reset` will restore\n * resolvers to the original proxied schema.\n *\n * @param schema - A `GraphQLSchema`.\n * @param options - An `options` object that accepts `scalars` and `resolvers` objects.\n * @returns A `ProxiedSchema` with `add`, `fork` and `reset` methods.\n *\n * @example\n * ```js\n *\n * const schema = createTestSchema(schemaWithTypeDefs, {\n * resolvers: {\n Query: {\n writer: () => ({\n name: \"Ada Lovelace\",\n }),\n }\n },\n scalars: {\n ID: () => \"1\",\n Int: () => 36,\n String: () => \"String\",\n Date: () => new Date(\"December 10, 1815 01:00:00\").toJSON().split(\"T\")[0],\n }\n });\n * ```\n * @since 3.9.0\n * @alpha\n */\nconst createTestSchema = (\n schemaWithTypeDefs: GraphQLSchema,\n options: TestSchemaOptions\n): ProxiedSchema => {\n let targetResolvers = { ...options.resolvers };\n let targetSchema = addResolversToSchema({\n schema: createMockSchema(schemaWithTypeDefs, options.scalars ?? {}),\n resolvers: targetResolvers,\n });\n\n const fns: TestSchemaFns = {\n add: ({ resolvers: newResolvers }) => {\n // @ts-ignore TODO(fixme): IResolvers type does not play well with our Resolvers\n targetResolvers = mergeResolvers([targetResolvers, newResolvers]);\n\n targetSchema = addResolversToSchema({\n schema: targetSchema,\n resolvers: targetResolvers,\n });\n\n return targetSchema as ProxiedSchema;\n },\n\n fork: ({ resolvers: newResolvers } = {}) => {\n return createTestSchema(targetSchema, {\n // @ts-ignore TODO(fixme): IResolvers type does not play well with our Resolvers\n resolvers:\n mergeResolvers([targetResolvers, newResolvers]) ?? targetResolvers,\n scalars: options.scalars,\n });\n },\n\n reset: () => {\n targetSchema = addResolversToSchema({\n schema: schemaWithTypeDefs,\n resolvers: options.resolvers,\n });\n },\n };\n\n const schema = new Proxy(targetSchema, {\n get(_target, p) {\n if (p in fns) {\n return Reflect.get(fns, p);\n }\n\n // An optimization that eliminates round-trips through the proxy\n // on class methods invoked via `this` on a base class instance wrapped by\n // the proxy.\n //\n // For example, consider the following class:\n //\n // class Base {\n // foo(){\n // this.bar()\n // }\n // bar(){\n // ...\n // }\n // }\n //\n // Calling `proxy.foo()` would call `foo` with `this` being the proxy.\n // This would result in calling `proxy.bar()` which would again invoke\n // the proxy to resolve `bar` and call that method.\n //\n // Instead, calls to `proxy.foo()` should result in a call to\n // `innerObject.foo()` with a `this` of `innerObject`, and that call\n // should directly call `innerObject.bar()`.\n\n const property = Reflect.get(targetSchema, p);\n if (typeof property === \"function\") {\n return property.bind(targetSchema);\n }\n return property;\n },\n });\n\n return schema as ProxiedSchema;\n};\n\nexport { createTestSchema };\n"]}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var schema = require('@graphql-tools/schema');
|
|
7
|
+
var merge = require('@graphql-tools/merge');
|
|
8
|
+
var graphql = require('graphql');
|
|
9
|
+
var utilities = require('../../utilities');
|
|
10
|
+
var utils = require('@graphql-tools/utils');
|
|
11
|
+
var core = require('../../core');
|
|
12
|
+
|
|
13
|
+
var takeRandom = function (arr) { return arr[Math.floor(Math.random() * arr.length)]; };
|
|
14
|
+
var createMockSchema = function (staticSchema, mocks) {
|
|
15
|
+
var _a;
|
|
16
|
+
var getType = function (typeName) {
|
|
17
|
+
var type = staticSchema.getType(typeName);
|
|
18
|
+
if (!type || !(graphql.isObjectType(type) || graphql.isInterfaceType(type))) {
|
|
19
|
+
throw new Error("".concat(typeName, " does not exist on schema or is not an object or interface"));
|
|
20
|
+
}
|
|
21
|
+
return type;
|
|
22
|
+
};
|
|
23
|
+
var getFieldType = function (typeName, fieldName) {
|
|
24
|
+
if (fieldName === "__typename") {
|
|
25
|
+
return graphql.GraphQLString;
|
|
26
|
+
}
|
|
27
|
+
var type = getType(typeName);
|
|
28
|
+
var field = type.getFields()[fieldName];
|
|
29
|
+
if (!field) {
|
|
30
|
+
throw new Error("".concat(fieldName, " does not exist on type ").concat(typeName));
|
|
31
|
+
}
|
|
32
|
+
return field.type;
|
|
33
|
+
};
|
|
34
|
+
var generateValueFromType = function (fieldType) {
|
|
35
|
+
var nullableType = graphql.getNullableType(fieldType);
|
|
36
|
+
if (graphql.isScalarType(nullableType)) {
|
|
37
|
+
var mockFn = mocks[nullableType.name];
|
|
38
|
+
if (typeof mockFn !== "function") {
|
|
39
|
+
throw new Error("No mock defined for type \"".concat(nullableType.name, "\""));
|
|
40
|
+
}
|
|
41
|
+
return mockFn();
|
|
42
|
+
}
|
|
43
|
+
else if (graphql.isEnumType(nullableType)) {
|
|
44
|
+
var mockFn = mocks[nullableType.name];
|
|
45
|
+
if (typeof mockFn === "function")
|
|
46
|
+
return mockFn();
|
|
47
|
+
var values = nullableType.getValues().map(function (v) { return v.value; });
|
|
48
|
+
return takeRandom(values);
|
|
49
|
+
}
|
|
50
|
+
else if (graphql.isObjectType(nullableType)) {
|
|
51
|
+
return {};
|
|
52
|
+
}
|
|
53
|
+
else if (graphql.isListType(nullableType)) {
|
|
54
|
+
return tslib.__spreadArray([], new Array(2), true).map(function () {
|
|
55
|
+
return generateValueFromType(nullableType.ofType);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
else if (graphql.isAbstractType(nullableType)) {
|
|
59
|
+
var mock = mocks[nullableType.name];
|
|
60
|
+
var typeName = void 0;
|
|
61
|
+
var values = {};
|
|
62
|
+
if (!mock) {
|
|
63
|
+
typeName = takeRandom(staticSchema.getPossibleTypes(nullableType).map(function (t) { return t.name; }));
|
|
64
|
+
}
|
|
65
|
+
else if (typeof mock === "function") {
|
|
66
|
+
var mockRes = mock();
|
|
67
|
+
if (mockRes === null)
|
|
68
|
+
return null;
|
|
69
|
+
if (!utilities.isNonNullObject(mockRes)) {
|
|
70
|
+
throw new Error("Value returned by the mock for ".concat(nullableType.name, " is not an object or null"));
|
|
71
|
+
}
|
|
72
|
+
values = mockRes;
|
|
73
|
+
if (typeof values["__typename"] !== "string") {
|
|
74
|
+
throw new Error("Please return a __typename in \"".concat(nullableType.name, "\""));
|
|
75
|
+
}
|
|
76
|
+
typeName = values["__typename"];
|
|
77
|
+
}
|
|
78
|
+
else if (utilities.isNonNullObject(mock) &&
|
|
79
|
+
typeof mock["__typename"] === "function") {
|
|
80
|
+
var mockRes = mock["__typename"]();
|
|
81
|
+
if (typeof mockRes !== "string") {
|
|
82
|
+
throw new Error("'__typename' returned by the mock for abstract type ".concat(nullableType.name, " is not a string"));
|
|
83
|
+
}
|
|
84
|
+
typeName = mockRes;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
throw new Error("Please return a __typename in \"".concat(nullableType.name, "\""));
|
|
88
|
+
}
|
|
89
|
+
return typeName;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
throw new Error("".concat(nullableType, " not implemented"));
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
var isRootType = function (type, schema) {
|
|
96
|
+
var rootTypeNames = utils.getRootTypeNames(schema);
|
|
97
|
+
return rootTypeNames.has(type.name);
|
|
98
|
+
};
|
|
99
|
+
var mockResolver = function (source, args, contex, info) {
|
|
100
|
+
var defaultResolvedValue = graphql.defaultFieldResolver(source, args, contex, info);
|
|
101
|
+
if (defaultResolvedValue !== undefined)
|
|
102
|
+
return defaultResolvedValue;
|
|
103
|
+
if (isRootType(info.parentType, info.schema)) {
|
|
104
|
+
return {
|
|
105
|
+
typeName: info.parentType.name,
|
|
106
|
+
key: "ROOT",
|
|
107
|
+
fieldName: info.fieldName,
|
|
108
|
+
fieldArgs: args,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
if (defaultResolvedValue === undefined) {
|
|
112
|
+
var fieldType = getFieldType(info.parentType.name, info.fieldName);
|
|
113
|
+
return generateValueFromType(fieldType);
|
|
114
|
+
}
|
|
115
|
+
return undefined;
|
|
116
|
+
};
|
|
117
|
+
return utils.mapSchema(staticSchema, (_a = {},
|
|
118
|
+
_a[utils.MapperKind.OBJECT_FIELD] = function (fieldConfig) {
|
|
119
|
+
var newFieldConfig = tslib.__assign({}, fieldConfig);
|
|
120
|
+
var oldResolver = fieldConfig.resolve;
|
|
121
|
+
if (!oldResolver) {
|
|
122
|
+
newFieldConfig.resolve = mockResolver;
|
|
123
|
+
}
|
|
124
|
+
return newFieldConfig;
|
|
125
|
+
},
|
|
126
|
+
_a[utils.MapperKind.ABSTRACT_TYPE] = function (type) {
|
|
127
|
+
if (type.resolveType != null && type.resolveType.length) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
var typeResolver = function (typename) {
|
|
131
|
+
return typename;
|
|
132
|
+
};
|
|
133
|
+
if (graphql.isUnionType(type)) {
|
|
134
|
+
return new graphql.GraphQLUnionType(tslib.__assign(tslib.__assign({}, type.toConfig()), { resolveType: typeResolver }));
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
return new graphql.GraphQLInterfaceType(tslib.__assign(tslib.__assign({}, type.toConfig()), { resolveType: typeResolver }));
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
_a));
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
var createTestSchema = function (schemaWithTypeDefs, options) {
|
|
144
|
+
var _a;
|
|
145
|
+
var targetResolvers = tslib.__assign({}, options.resolvers);
|
|
146
|
+
var targetSchema = schema.addResolversToSchema({
|
|
147
|
+
schema: createMockSchema(schemaWithTypeDefs, (_a = options.scalars) !== null && _a !== void 0 ? _a : {}),
|
|
148
|
+
resolvers: targetResolvers,
|
|
149
|
+
});
|
|
150
|
+
var fns = {
|
|
151
|
+
add: function (_a) {
|
|
152
|
+
var newResolvers = _a.resolvers;
|
|
153
|
+
targetResolvers = merge.mergeResolvers([targetResolvers, newResolvers]);
|
|
154
|
+
targetSchema = schema.addResolversToSchema({
|
|
155
|
+
schema: targetSchema,
|
|
156
|
+
resolvers: targetResolvers,
|
|
157
|
+
});
|
|
158
|
+
return targetSchema;
|
|
159
|
+
},
|
|
160
|
+
fork: function (_a) {
|
|
161
|
+
var _b;
|
|
162
|
+
var _c = _a === void 0 ? {} : _a, newResolvers = _c.resolvers;
|
|
163
|
+
return createTestSchema(targetSchema, {
|
|
164
|
+
resolvers: (_b = merge.mergeResolvers([targetResolvers, newResolvers])) !== null && _b !== void 0 ? _b : targetResolvers,
|
|
165
|
+
scalars: options.scalars,
|
|
166
|
+
});
|
|
167
|
+
},
|
|
168
|
+
reset: function () {
|
|
169
|
+
targetSchema = schema.addResolversToSchema({
|
|
170
|
+
schema: schemaWithTypeDefs,
|
|
171
|
+
resolvers: options.resolvers,
|
|
172
|
+
});
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
var schema$1 = new Proxy(targetSchema, {
|
|
176
|
+
get: function (_target, p) {
|
|
177
|
+
if (p in fns) {
|
|
178
|
+
return Reflect.get(fns, p);
|
|
179
|
+
}
|
|
180
|
+
var property = Reflect.get(targetSchema, p);
|
|
181
|
+
if (typeof property === "function") {
|
|
182
|
+
return property.bind(targetSchema);
|
|
183
|
+
}
|
|
184
|
+
return property;
|
|
185
|
+
},
|
|
186
|
+
});
|
|
187
|
+
return schema$1;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
function withCleanup(item, cleanup) {
|
|
191
|
+
var _a;
|
|
192
|
+
return tslib.__assign(tslib.__assign({}, item), (_a = {}, _a[Symbol.dispose] = function () {
|
|
193
|
+
cleanup(item);
|
|
194
|
+
if (Symbol.dispose in item) {
|
|
195
|
+
item[Symbol.dispose]();
|
|
196
|
+
}
|
|
197
|
+
}, _a));
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function wait(ms) {
|
|
201
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
202
|
+
return tslib.__generator(this, function (_a) {
|
|
203
|
+
return [2 , new Promise(function (resolve) { return setTimeout(resolve, ms); })];
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
var createSchemaFetch = function (schema, mockFetchOpts) {
|
|
209
|
+
var _a, _b, _c, _d;
|
|
210
|
+
if (mockFetchOpts === void 0) { mockFetchOpts = { validate: true }; }
|
|
211
|
+
var prevFetch = window.fetch;
|
|
212
|
+
var delayMin = (_b = (_a = mockFetchOpts.delay) === null || _a === void 0 ? void 0 : _a.min) !== null && _b !== void 0 ? _b : 3;
|
|
213
|
+
var delayMax = (_d = (_c = mockFetchOpts.delay) === null || _c === void 0 ? void 0 : _c.max) !== null && _d !== void 0 ? _d : delayMin + 2;
|
|
214
|
+
if (delayMin > delayMax) {
|
|
215
|
+
throw new Error("Please configure a minimum delay that is less than the maximum delay. The default minimum delay is 3ms.");
|
|
216
|
+
}
|
|
217
|
+
var mockFetch = function (_uri, options) { return tslib.__awaiter(void 0, void 0, void 0, function () {
|
|
218
|
+
var randomDelay, body, document, validationErrors, result, stringifiedResult;
|
|
219
|
+
return tslib.__generator(this, function (_a) {
|
|
220
|
+
switch (_a.label) {
|
|
221
|
+
case 0:
|
|
222
|
+
if (!(delayMin > 0)) return [3 , 2];
|
|
223
|
+
randomDelay = Math.random() * (delayMax - delayMin) + delayMin;
|
|
224
|
+
return [4 , wait(randomDelay)];
|
|
225
|
+
case 1:
|
|
226
|
+
_a.sent();
|
|
227
|
+
_a.label = 2;
|
|
228
|
+
case 2:
|
|
229
|
+
body = JSON.parse(options.body);
|
|
230
|
+
document = core.gql(body.query);
|
|
231
|
+
if (mockFetchOpts.validate) {
|
|
232
|
+
validationErrors = [];
|
|
233
|
+
try {
|
|
234
|
+
validationErrors = graphql.validate(schema, document);
|
|
235
|
+
}
|
|
236
|
+
catch (e) {
|
|
237
|
+
validationErrors = [
|
|
238
|
+
new core.ApolloError({ graphQLErrors: [e] }),
|
|
239
|
+
];
|
|
240
|
+
}
|
|
241
|
+
if ((validationErrors === null || validationErrors === void 0 ? void 0 : validationErrors.length) > 0) {
|
|
242
|
+
return [2 , new Response(JSON.stringify({ errors: validationErrors }))];
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return [4 , graphql.execute({
|
|
246
|
+
schema: schema,
|
|
247
|
+
document: document,
|
|
248
|
+
variableValues: body.variables,
|
|
249
|
+
operationName: body.operationName,
|
|
250
|
+
})];
|
|
251
|
+
case 3:
|
|
252
|
+
result = _a.sent();
|
|
253
|
+
stringifiedResult = JSON.stringify(result);
|
|
254
|
+
return [2 , new Response(stringifiedResult)];
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
}); };
|
|
258
|
+
function mockGlobal() {
|
|
259
|
+
window.fetch = mockFetch;
|
|
260
|
+
var restore = function () {
|
|
261
|
+
if (window.fetch === mockFetch) {
|
|
262
|
+
window.fetch = prevFetch;
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
return withCleanup({ restore: restore }, restore);
|
|
266
|
+
}
|
|
267
|
+
return Object.assign(mockFetch, {
|
|
268
|
+
mockGlobal: mockGlobal,
|
|
269
|
+
});
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
exports.createSchemaFetch = createSchemaFetch;
|
|
273
|
+
exports.createTestSchema = createTestSchema;
|
|
274
|
+
//# sourceMappingURL=experimental.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"experimental.cjs","sources":["graphql-tools/utils.js","createTestSchema.js","../internal/disposables/withCleanup.js","../core/wait.js","createSchemaFetch.js"],"sourcesContent":["import { __assign, __spreadArray } from \"tslib\";\nimport { GraphQLInterfaceType, GraphQLString, GraphQLUnionType, defaultFieldResolver, getNullableType, isAbstractType, isEnumType, isInterfaceType, isListType, isObjectType, isScalarType, isUnionType, } from \"graphql\";\nimport { isNonNullObject } from \"../../../utilities/index.js\";\nimport { MapperKind, mapSchema, getRootTypeNames } from \"@graphql-tools/utils\";\n// Taken from @graphql-tools/mock:\n// https://github.com/ardatan/graphql-tools/blob/4b56b04d69b02919f6c5fa4f97d33da63f36e8c8/packages/mock/src/utils.ts#L20\nvar takeRandom = function (arr) { return arr[Math.floor(Math.random() * arr.length)]; };\n/**\n * A function that accepts a static `schema` and a `mocks` object for specifying\n * default scalar mocks and returns a `GraphQLSchema`.\n *\n * @param staticSchema - A static `GraphQLSchema`.\n * @param mocks - An object containing scalar mocks.\n * @returns A `GraphQLSchema` with scalar mocks.\n *\n * @example\n * ```js\n * const mockedSchema = createMockSchema(schema, {\n ID: () => \"1\",\n Int: () => 42,\n String: () => \"String\",\n Date: () => new Date(\"January 1, 2024 01:00:00\").toJSON().split(\"T\")[0],\n });\n * ```\n * @since 3.10.0\n * @alpha\n */\nvar createMockSchema = function (staticSchema, mocks) {\n var _a;\n // Taken from @graphql-tools/mock:\n // https://github.com/ardatan/graphql-tools/blob/5ed60e44f94868f976cd28fe1b6a764fb146bbe9/packages/mock/src/MockStore.ts#L613\n var getType = function (typeName) {\n var type = staticSchema.getType(typeName);\n if (!type || !(isObjectType(type) || isInterfaceType(type))) {\n throw new Error(\"\".concat(typeName, \" does not exist on schema or is not an object or interface\"));\n }\n return type;\n };\n // Taken from @graphql-tools/mock:\n // https://github.com/ardatan/graphql-tools/blob/5ed60e44f94868f976cd28fe1b6a764fb146bbe9/packages/mock/src/MockStore.ts#L597\n var getFieldType = function (typeName, fieldName) {\n if (fieldName === \"__typename\") {\n return GraphQLString;\n }\n var type = getType(typeName);\n var field = type.getFields()[fieldName];\n if (!field) {\n throw new Error(\"\".concat(fieldName, \" does not exist on type \").concat(typeName));\n }\n return field.type;\n };\n // Taken from @graphql-tools/mock:\n // https://github.com/ardatan/graphql-tools/blob/5ed60e44f94868f976cd28fe1b6a764fb146bbe9/packages/mock/src/MockStore.ts#L527\n var generateValueFromType = function (fieldType) {\n var nullableType = getNullableType(fieldType);\n if (isScalarType(nullableType)) {\n var mockFn = mocks[nullableType.name];\n if (typeof mockFn !== \"function\") {\n throw new Error(\"No mock defined for type \\\"\".concat(nullableType.name, \"\\\"\"));\n }\n return mockFn();\n }\n else if (isEnumType(nullableType)) {\n var mockFn = mocks[nullableType.name];\n if (typeof mockFn === \"function\")\n return mockFn();\n var values = nullableType.getValues().map(function (v) { return v.value; });\n return takeRandom(values);\n }\n else if (isObjectType(nullableType)) {\n return {};\n }\n else if (isListType(nullableType)) {\n return __spreadArray([], new Array(2), true).map(function () {\n return generateValueFromType(nullableType.ofType);\n });\n }\n else if (isAbstractType(nullableType)) {\n var mock = mocks[nullableType.name];\n var typeName = void 0;\n var values = {};\n if (!mock) {\n typeName = takeRandom(staticSchema.getPossibleTypes(nullableType).map(function (t) { return t.name; }));\n }\n else if (typeof mock === \"function\") {\n var mockRes = mock();\n if (mockRes === null)\n return null;\n if (!isNonNullObject(mockRes)) {\n throw new Error(\"Value returned by the mock for \".concat(nullableType.name, \" is not an object or null\"));\n }\n values = mockRes;\n if (typeof values[\"__typename\"] !== \"string\") {\n throw new Error(\"Please return a __typename in \\\"\".concat(nullableType.name, \"\\\"\"));\n }\n typeName = values[\"__typename\"];\n }\n else if (isNonNullObject(mock) &&\n typeof mock[\"__typename\"] === \"function\") {\n var mockRes = mock[\"__typename\"]();\n if (typeof mockRes !== \"string\") {\n throw new Error(\"'__typename' returned by the mock for abstract type \".concat(nullableType.name, \" is not a string\"));\n }\n typeName = mockRes;\n }\n else {\n throw new Error(\"Please return a __typename in \\\"\".concat(nullableType.name, \"\\\"\"));\n }\n return typeName;\n }\n else {\n throw new Error(\"\".concat(nullableType, \" not implemented\"));\n }\n };\n // Taken from @graphql-tools/mock:\n // https://github.com/ardatan/graphql-tools/blob/5ed60e44f94868f976cd28fe1b6a764fb146bbe9/packages/mock/src/utils.ts#L53\n var isRootType = function (type, schema) {\n var rootTypeNames = getRootTypeNames(schema);\n return rootTypeNames.has(type.name);\n };\n // Taken from @graphql-tools/mock:\n // https://github.com/ardatan/graphql-tools/blob/5ed60e44f94868f976cd28fe1b6a764fb146bbe9/packages/mock/src/addMocksToSchema.ts#L123\n var mockResolver = function (source, args, contex, info) {\n var defaultResolvedValue = defaultFieldResolver(source, args, contex, info);\n // priority to default resolved value\n if (defaultResolvedValue !== undefined)\n return defaultResolvedValue;\n // we have to handle the root mutation, root query and root subscription types\n // differently, because no resolver is called at the root\n if (isRootType(info.parentType, info.schema)) {\n return {\n typeName: info.parentType.name,\n key: \"ROOT\",\n fieldName: info.fieldName,\n fieldArgs: args,\n };\n }\n if (defaultResolvedValue === undefined) {\n var fieldType = getFieldType(info.parentType.name, info.fieldName);\n return generateValueFromType(fieldType);\n }\n return undefined;\n };\n // Taken from @graphql-tools/mock:\n // https://github.com/ardatan/graphql-tools/blob/5ed60e44f94868f976cd28fe1b6a764fb146bbe9/packages/mock/src/addMocksToSchema.ts#L176\n return mapSchema(staticSchema, (_a = {},\n _a[MapperKind.OBJECT_FIELD] = function (fieldConfig) {\n var newFieldConfig = __assign({}, fieldConfig);\n var oldResolver = fieldConfig.resolve;\n if (!oldResolver) {\n newFieldConfig.resolve = mockResolver;\n }\n return newFieldConfig;\n },\n _a[MapperKind.ABSTRACT_TYPE] = function (type) {\n if (type.resolveType != null && type.resolveType.length) {\n return;\n }\n var typeResolver = function (typename) {\n return typename;\n };\n if (isUnionType(type)) {\n return new GraphQLUnionType(__assign(__assign({}, type.toConfig()), { resolveType: typeResolver }));\n }\n else {\n return new GraphQLInterfaceType(__assign(__assign({}, type.toConfig()), { resolveType: typeResolver }));\n }\n },\n _a));\n};\nexport { createMockSchema };\n//# sourceMappingURL=utils.js.map","import { __assign } from \"tslib\";\nimport { addResolversToSchema } from \"@graphql-tools/schema\";\nimport { mergeResolvers } from \"@graphql-tools/merge\";\nimport { createMockSchema } from \"./graphql-tools/utils.js\";\n/**\n * A function that creates a [Proxy object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy)\n * around a given `schema` with `resolvers`. This proxied schema can be used to\n * progressively layer resolvers on top of the original schema using the `add`\n * method. The `fork` method can be used to create a new proxied schema which\n * can be modified independently of the original schema. `reset` will restore\n * resolvers to the original proxied schema.\n *\n * @param schema - A `GraphQLSchema`.\n * @param options - An `options` object that accepts `scalars` and `resolvers` objects.\n * @returns A `ProxiedSchema` with `add`, `fork` and `reset` methods.\n *\n * @example\n * ```js\n *\n * const schema = createTestSchema(schemaWithTypeDefs, {\n * resolvers: {\n Query: {\n writer: () => ({\n name: \"Ada Lovelace\",\n }),\n }\n },\n scalars: {\n ID: () => \"1\",\n Int: () => 36,\n String: () => \"String\",\n Date: () => new Date(\"December 10, 1815 01:00:00\").toJSON().split(\"T\")[0],\n }\n });\n * ```\n * @since 3.9.0\n * @alpha\n */\nvar createTestSchema = function (schemaWithTypeDefs, options) {\n var _a;\n var targetResolvers = __assign({}, options.resolvers);\n var targetSchema = addResolversToSchema({\n schema: createMockSchema(schemaWithTypeDefs, (_a = options.scalars) !== null && _a !== void 0 ? _a : {}),\n resolvers: targetResolvers,\n });\n var fns = {\n add: function (_a) {\n var newResolvers = _a.resolvers;\n // @ts-ignore TODO(fixme): IResolvers type does not play well with our Resolvers\n targetResolvers = mergeResolvers([targetResolvers, newResolvers]);\n targetSchema = addResolversToSchema({\n schema: targetSchema,\n resolvers: targetResolvers,\n });\n return targetSchema;\n },\n fork: function (_a) {\n var _b;\n var _c = _a === void 0 ? {} : _a, newResolvers = _c.resolvers;\n return createTestSchema(targetSchema, {\n // @ts-ignore TODO(fixme): IResolvers type does not play well with our Resolvers\n resolvers: (_b = mergeResolvers([targetResolvers, newResolvers])) !== null && _b !== void 0 ? _b : targetResolvers,\n scalars: options.scalars,\n });\n },\n reset: function () {\n targetSchema = addResolversToSchema({\n schema: schemaWithTypeDefs,\n resolvers: options.resolvers,\n });\n },\n };\n var schema = new Proxy(targetSchema, {\n get: function (_target, p) {\n if (p in fns) {\n return Reflect.get(fns, p);\n }\n // An optimization that eliminates round-trips through the proxy\n // on class methods invoked via `this` on a base class instance wrapped by\n // the proxy.\n //\n // For example, consider the following class:\n //\n // class Base {\n // foo(){\n // this.bar()\n // }\n // bar(){\n // ...\n // }\n // }\n //\n // Calling `proxy.foo()` would call `foo` with `this` being the proxy.\n // This would result in calling `proxy.bar()` which would again invoke\n // the proxy to resolve `bar` and call that method.\n //\n // Instead, calls to `proxy.foo()` should result in a call to\n // `innerObject.foo()` with a `this` of `innerObject`, and that call\n // should directly call `innerObject.bar()`.\n var property = Reflect.get(targetSchema, p);\n if (typeof property === \"function\") {\n return property.bind(targetSchema);\n }\n return property;\n },\n });\n return schema;\n};\nexport { createTestSchema };\n//# sourceMappingURL=createTestSchema.js.map","import { __assign } from \"tslib\";\n/** @internal */\nexport function withCleanup(item, cleanup) {\n var _a;\n return __assign(__assign({}, item), (_a = {}, _a[Symbol.dispose] = function () {\n cleanup(item);\n // if `item` already has a cleanup function, we also need to call the original cleanup function\n // (e.g. if something is wrapped in `withCleanup` twice)\n if (Symbol.dispose in item) {\n item[Symbol.dispose]();\n }\n }, _a));\n}\n//# sourceMappingURL=withCleanup.js.map","import { __awaiter, __generator } from \"tslib\";\nexport function wait(ms) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, new Promise(function (resolve) { return setTimeout(resolve, ms); })];\n });\n });\n}\nexport function tick() {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, wait(0)];\n });\n });\n}\n//# sourceMappingURL=wait.js.map","import { __awaiter, __generator } from \"tslib\";\nimport { execute, validate } from \"graphql\";\nimport { ApolloError, gql } from \"../../core/index.js\";\nimport { withCleanup } from \"../internal/index.js\";\nimport { wait } from \"../core/wait.js\";\n/**\n * A function that accepts a static `schema` and a `mockFetchOpts` object and\n * returns a disposable object with `mock` and `restore` functions.\n *\n * The `mock` function is a mock fetch function that is set on the global\n * `window` object. This function intercepts any fetch requests and\n * returns a response by executing the operation against the provided schema.\n *\n * The `restore` function is a cleanup function that will restore the previous\n * `fetch`. It is automatically called if the function's return value is\n * declared with `using`. If your environment does not support the language\n * feature `using`, you should manually invoke the `restore` function.\n *\n * @param schema - A `GraphQLSchema`.\n * @param mockFetchOpts - Configuration options.\n * @returns An object with both `mock` and `restore` functions.\n *\n * @example\n * ```js\n * using _fetch = createSchemaFetch(schema); // automatically restores fetch after exiting the block\n *\n * const { restore } = createSchemaFetch(schema);\n * restore(); // manually restore fetch if `using` is not supported\n * ```\n * @since 3.10.0\n * @alpha\n */\nvar createSchemaFetch = function (schema, mockFetchOpts) {\n var _a, _b, _c, _d;\n if (mockFetchOpts === void 0) { mockFetchOpts = { validate: true }; }\n var prevFetch = window.fetch;\n var delayMin = (_b = (_a = mockFetchOpts.delay) === null || _a === void 0 ? void 0 : _a.min) !== null && _b !== void 0 ? _b : 3;\n var delayMax = (_d = (_c = mockFetchOpts.delay) === null || _c === void 0 ? void 0 : _c.max) !== null && _d !== void 0 ? _d : delayMin + 2;\n if (delayMin > delayMax) {\n throw new Error(\"Please configure a minimum delay that is less than the maximum delay. The default minimum delay is 3ms.\");\n }\n var mockFetch = function (_uri, options) { return __awaiter(void 0, void 0, void 0, function () {\n var randomDelay, body, document, validationErrors, result, stringifiedResult;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!(delayMin > 0)) return [3 /*break*/, 2];\n randomDelay = Math.random() * (delayMax - delayMin) + delayMin;\n return [4 /*yield*/, wait(randomDelay)];\n case 1:\n _a.sent();\n _a.label = 2;\n case 2:\n body = JSON.parse(options.body);\n document = gql(body.query);\n if (mockFetchOpts.validate) {\n validationErrors = [];\n try {\n validationErrors = validate(schema, document);\n }\n catch (e) {\n validationErrors = [\n new ApolloError({ graphQLErrors: [e] }),\n ];\n }\n if ((validationErrors === null || validationErrors === void 0 ? void 0 : validationErrors.length) > 0) {\n return [2 /*return*/, new Response(JSON.stringify({ errors: validationErrors }))];\n }\n }\n return [4 /*yield*/, execute({\n schema: schema,\n document: document,\n variableValues: body.variables,\n operationName: body.operationName,\n })];\n case 3:\n result = _a.sent();\n stringifiedResult = JSON.stringify(result);\n return [2 /*return*/, new Response(stringifiedResult)];\n }\n });\n }); };\n function mockGlobal() {\n window.fetch = mockFetch;\n var restore = function () {\n if (window.fetch === mockFetch) {\n window.fetch = prevFetch;\n }\n };\n return withCleanup({ restore: restore }, restore);\n }\n return Object.assign(mockFetch, {\n mockGlobal: mockGlobal,\n // if https://github.com/rbuckton/proposal-using-enforcement lands\n // [Symbol.enter]: mockGlobal\n });\n};\nexport { createSchemaFetch };\n//# sourceMappingURL=createSchemaFetch.js.map"],"names":["isObjectType","isInterfaceType","GraphQLString","getNullableType","isScalarType","isEnumType","isListType","__spreadArray","isAbstractType","isNonNullObject","getRootTypeNames","defaultFieldResolver","mapSchema","MapperKind","__assign","isUnionType","GraphQLUnionType","GraphQLInterfaceType","addResolversToSchema","mergeResolvers","schema","__awaiter","__generator","gql","validate","ApolloError","execute"],"mappings":";;;;;;;;;;;;AAMA,IAAI,UAAU,GAAG,UAAU,GAAG,EAAE,EAAE,OAAO,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;AAqBxF,IAAI,gBAAgB,GAAG,UAAU,YAAY,EAAE,KAAK,EAAE;AACtD,IAAI,IAAI,EAAE,CAAC;AAGX,IAAI,IAAI,OAAO,GAAG,UAAU,QAAQ,EAAE;AACtC,QAAQ,IAAI,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAClD,QAAQ,IAAI,CAAC,IAAI,IAAI,EAAEA,oBAAY,CAAC,IAAI,CAAC,IAAIC,uBAAe,CAAC,IAAI,CAAC,CAAC,EAAE;AACrE,YAAY,MAAM,IAAI,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,4DAA4D,CAAC,CAAC,CAAC;AAC/G,SA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