@apollo/client 4.0.9 → 4.0.10

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @apollo/client
2
2
 
3
+ ## 4.0.10
4
+
5
+ ### Patch Changes
6
+
7
+ - [#13045](https://github.com/apollographql/apollo-client/pull/13045) [`af4acdc`](https://github.com/apollographql/apollo-client/commit/af4acdc88bd3bac0d697ab300816241e4065842c) Thanks [@phryneas](https://github.com/phryneas)! - Fix memory leak #13036
8
+
3
9
  ## 4.0.9
4
10
 
5
11
  ### Patch Changes
@@ -7,7 +7,7 @@ const link_1 = require("@apollo/client/link");
7
7
  /**
8
8
  * `SchemaLink` is a terminating link that executes GraphQL operations against
9
9
  * a local GraphQL schema instead of making network requests. This is commonly
10
- * used for server-side rendering (SSR) and mocking dataa.
10
+ * used for server-side rendering (SSR) and mocking data.
11
11
  *
12
12
  * > [!NOTE]
13
13
  * > While `SchemaLink` can provide GraphQL results on the client, the GraphQL
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../../src/link/schema/index.ts"],"sourcesContent":["import type { GraphQLSchema } from \"graphql\";\nimport { execute, validate } from \"graphql\";\nimport { Observable } from \"rxjs\";\n\nimport { ApolloLink } from \"@apollo/client/link\";\n\nexport declare namespace SchemaLink {\n export namespace SchemaLinkDocumentationTypes {\n /**\n * A function that returns the resolver context for a given operation.\n *\n * This function is called for each operation and allows you to create\n * operation-specific context. This is useful when you need to include\n * information from the operation (like headers, variables, etc.) in the\n * resolver context.\n *\n * @param operation - The Apollo Link operation\n * @returns The resolver context object or a promise that resolves to the context\n *\n * @example\n *\n * ```ts\n * const link = new SchemaLink({\n * schema,\n * context: (operation) => {\n * return {\n * userId: operation.getContext().userId,\n * dataSources: {\n * userAPI: new UserAPI(),\n * },\n * };\n * },\n * });\n * ```\n */\n export function ResolverContextFunction(\n operation: ApolloLink.Operation\n ): SchemaLink.ResolverContext | PromiseLike<SchemaLink.ResolverContext>;\n }\n /**\n * The resolver context object passed to GraphQL resolvers.\n *\n * This context object is passed as the third parameter to GraphQL resolvers\n * and typically contains data-fetching connectors, authentication information,\n * and other request-specific data.\n */\n export type ResolverContext = Record<string, any>;\n\n /** {@inheritDoc @apollo/client/link/schema!SchemaLink.SchemaLinkDocumentationTypes.ResolverContextFunction:function(1)} */\n export type ResolverContextFunction = (\n operation: ApolloLink.Operation\n ) => SchemaLink.ResolverContext | PromiseLike<SchemaLink.ResolverContext>;\n\n /**\n * Options for configuring the `SchemaLink`.\n */\n export interface Options {\n /**\n * An executable GraphQL schema to use for operation execution.\n *\n * @remarks\n *\n * This should be a complete, executable GraphQL schema created using\n * tools like `makeExecutableSchema` from `@graphql-tools/schema` or\n * `buildSchema` from `graphql`.\n *\n * @example\n *\n * ```ts\n * import { makeExecutableSchema } from \"@graphql-tools/schema\";\n *\n * const schema = makeExecutableSchema({\n * typeDefs,\n * resolvers,\n * });\n *\n * const link = new SchemaLink({ schema });\n * ```\n */\n schema: GraphQLSchema;\n\n /**\n * The root value passed to root-level resolvers. It's typically not used in\n * most schemas but can be useful for certain advanced patterns.\n */\n rootValue?: any;\n\n /**\n * Context object or function that returns the context object to provide to\n * resolvers. The context is passed as the third parameter to all GraphQL\n * resolvers.\n *\n * - If a static object is provided, the same context will be used for all\n * operations\n * - If a function is provided, the function is called for each operation to\n * generate operation-specific context\n */\n context?: SchemaLink.ResolverContext | SchemaLink.ResolverContextFunction;\n\n /**\n * Whether to validate incoming queries against the schema before execution.\n *\n * When enabled, queries will be validated against the schema before execution,\n * and validation errors will be returned in the result's `errors` array,\n * just like a remote GraphQL server would.\n *\n * This is useful for testing and development to catch query errors early,\n * but may add overhead in production environments.\n *\n * @defaultValue false\n */\n validate?: boolean;\n }\n}\n\n/**\n * `SchemaLink` is a terminating link that executes GraphQL operations against\n * a local GraphQL schema instead of making network requests. This is commonly\n * used for server-side rendering (SSR) and mocking dataa.\n *\n * > [!NOTE]\n * > While `SchemaLink` can provide GraphQL results on the client, the GraphQL\n * > execution layer is [quite large](https://bundlephobia.com/result?p=graphql) for practical client-side use.\n * > For client-side state management, consider Apollo Client's [local state management](https://apollographql.com/docs/react/local-state/local-state-management/)\n * > functionality instead, which integrates with the Apollo Client cache.\n *\n * @example\n *\n * ```ts\n * import { SchemaLink } from \"@apollo/client/link/schema\";\n * import schema from \"./path/to/your/schema\";\n *\n * const link = new SchemaLink({ schema });\n * ```\n */\nexport class SchemaLink extends ApolloLink {\n public schema: SchemaLink.Options[\"schema\"];\n public rootValue: SchemaLink.Options[\"rootValue\"];\n public context: SchemaLink.Options[\"context\"];\n public validate: boolean;\n\n constructor(options: SchemaLink.Options) {\n super();\n this.schema = options.schema;\n this.rootValue = options.rootValue;\n this.context = options.context;\n this.validate = !!options.validate;\n }\n\n public request(\n operation: ApolloLink.Operation\n ): Observable<ApolloLink.Result> {\n return new Observable<ApolloLink.Result>((observer) => {\n new Promise<SchemaLink.ResolverContext>((resolve) =>\n resolve(\n typeof this.context === \"function\" ?\n this.context(operation)\n : this.context\n )\n )\n .then((context) => {\n if (this.validate) {\n const validationErrors = validate(this.schema, operation.query);\n if (validationErrors.length > 0) {\n return { errors: validationErrors };\n }\n }\n\n return execute({\n schema: this.schema,\n document: operation.query,\n rootValue: this.rootValue,\n contextValue: context,\n variableValues: operation.variables,\n operationName: operation.operationName,\n });\n })\n .then((data) => {\n if (!observer.closed) {\n observer.next(data);\n observer.complete();\n }\n })\n .catch((error) => {\n if (!observer.closed) {\n observer.error(error);\n }\n });\n });\n }\n}\n"],"names":[],"mappings":";;;AACA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACA,CAAA,CAAA,CAAA,CA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AAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../../src/link/schema/index.ts"],"sourcesContent":["import type { GraphQLSchema } from \"graphql\";\nimport { execute, validate } from \"graphql\";\nimport { Observable } from \"rxjs\";\n\nimport { ApolloLink } from \"@apollo/client/link\";\n\nexport declare namespace SchemaLink {\n export namespace SchemaLinkDocumentationTypes {\n /**\n * A function that returns the resolver context for a given operation.\n *\n * This function is called for each operation and allows you to create\n * operation-specific context. This is useful when you need to include\n * information from the operation (like headers, variables, etc.) in the\n * resolver context.\n *\n * @param operation - The Apollo Link operation\n * @returns The resolver context object or a promise that resolves to the context\n *\n * @example\n *\n * ```ts\n * const link = new SchemaLink({\n * schema,\n * context: (operation) => {\n * return {\n * userId: operation.getContext().userId,\n * dataSources: {\n * userAPI: new UserAPI(),\n * },\n * };\n * },\n * });\n * ```\n */\n export function ResolverContextFunction(\n operation: ApolloLink.Operation\n ): SchemaLink.ResolverContext | PromiseLike<SchemaLink.ResolverContext>;\n }\n /**\n * The resolver context object passed to GraphQL resolvers.\n *\n * This context object is passed as the third parameter to GraphQL resolvers\n * and typically contains data-fetching connectors, authentication information,\n * and other request-specific data.\n */\n export type ResolverContext = Record<string, any>;\n\n /** {@inheritDoc @apollo/client/link/schema!SchemaLink.SchemaLinkDocumentationTypes.ResolverContextFunction:function(1)} */\n export type ResolverContextFunction = (\n operation: ApolloLink.Operation\n ) => SchemaLink.ResolverContext | PromiseLike<SchemaLink.ResolverContext>;\n\n /**\n * Options for configuring the `SchemaLink`.\n */\n export interface Options {\n /**\n * An executable GraphQL schema to use for operation execution.\n *\n * @remarks\n *\n * This should be a complete, executable GraphQL schema created using\n * tools like `makeExecutableSchema` from `@graphql-tools/schema` or\n * `buildSchema` from `graphql`.\n *\n * @example\n *\n * ```ts\n * import { makeExecutableSchema } from \"@graphql-tools/schema\";\n *\n * const schema = makeExecutableSchema({\n * typeDefs,\n * resolvers,\n * });\n *\n * const link = new SchemaLink({ schema });\n * ```\n */\n schema: GraphQLSchema;\n\n /**\n * The root value passed to root-level resolvers. It's typically not used in\n * most schemas but can be useful for certain advanced patterns.\n */\n rootValue?: any;\n\n /**\n * Context object or function that returns the context object to provide to\n * resolvers. The context is passed as the third parameter to all GraphQL\n * resolvers.\n *\n * - If a static object is provided, the same context will be used for all\n * operations\n * - If a function is provided, the function is called for each operation to\n * generate operation-specific context\n */\n context?: SchemaLink.ResolverContext | SchemaLink.ResolverContextFunction;\n\n /**\n * Whether to validate incoming queries against the schema before execution.\n *\n * When enabled, queries will be validated against the schema before execution,\n * and validation errors will be returned in the result's `errors` array,\n * just like a remote GraphQL server would.\n *\n * This is useful for testing and development to catch query errors early,\n * but may add overhead in production environments.\n *\n * @defaultValue false\n */\n validate?: boolean;\n }\n}\n\n/**\n * `SchemaLink` is a terminating link that executes GraphQL operations against\n * a local GraphQL schema instead of making network requests. This is commonly\n * used for server-side rendering (SSR) and mocking data.\n *\n * > [!NOTE]\n * > While `SchemaLink` can provide GraphQL results on the client, the GraphQL\n * > execution layer is [quite large](https://bundlephobia.com/result?p=graphql) for practical client-side use.\n * > For client-side state management, consider Apollo Client's [local state management](https://apollographql.com/docs/react/local-state/local-state-management/)\n * > functionality instead, which integrates with the Apollo Client cache.\n *\n * @example\n *\n * ```ts\n * import { SchemaLink } from \"@apollo/client/link/schema\";\n * import schema from \"./path/to/your/schema\";\n *\n * const link = new SchemaLink({ schema });\n * ```\n */\nexport class SchemaLink extends ApolloLink {\n public schema: SchemaLink.Options[\"schema\"];\n public rootValue: SchemaLink.Options[\"rootValue\"];\n public context: SchemaLink.Options[\"context\"];\n public validate: boolean;\n\n constructor(options: SchemaLink.Options) {\n super();\n this.schema = options.schema;\n this.rootValue = options.rootValue;\n this.context = options.context;\n this.validate = !!options.validate;\n }\n\n public request(\n operation: ApolloLink.Operation\n ): Observable<ApolloLink.Result> {\n return new Observable<ApolloLink.Result>((observer) => {\n new Promise<SchemaLink.ResolverContext>((resolve) =>\n resolve(\n typeof this.context === \"function\" ?\n this.context(operation)\n : this.context\n )\n )\n .then((context) => {\n if (this.validate) {\n const validationErrors = validate(this.schema, operation.query);\n if (validationErrors.length > 0) {\n return { errors: validationErrors };\n }\n }\n\n return execute({\n schema: this.schema,\n document: operation.query,\n rootValue: this.rootValue,\n contextValue: context,\n variableValues: operation.variables,\n operationName: operation.operationName,\n });\n })\n .then((data) => {\n if (!observer.closed) {\n observer.next(data);\n observer.complete();\n }\n })\n .catch((error) => {\n if (!observer.closed) {\n observer.error(error);\n }\n });\n });\n }\n}\n"],"names":[],"mappings":";;;AACA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAEA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AA+GA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;CAmBA,CAAA;AACA,CAAA,CAAA,CAAA,CAAA,EAAa,CAAb,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CA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CAA1B,CAAA,CAAA,CAA8B,CAAC;oBACnB,CAAZ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAoB,CAAC,CAArB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA6B,CAA7B,CAA+B;gBACrB;YACF,CAAC;gBACT,CAAS,CAAT,CAAA,CAAA,CAAA,CAAc,CAAC,CAAC,CAAhB,CAAA,CAAA,CAAA,CAAqB,EAAE,CAAvB,EAAA;gBACU,CAAV,EAAA,CAAc,CAAC,CAAf,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAuB,CAAC,CAAxB,CAAA,CAAA,CAAA,CAAA,CAA8B,EAAE;oBACpB,CAAZ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAoB,CAAC,CAArB,CAAA,CAAA,CAAA,CAA0B,CAAC,CAA3B,CAAA,CAAA,CAAA,CAAgC,CAAC;gBACvB;YACF,CAAC,CAAC;QACN,CAAC,CAAC;IACJ;AACF;AAvDA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;"}
@@ -129,7 +129,7 @@ export declare namespace SchemaLink {
129
129
  /**
130
130
  * `SchemaLink` is a terminating link that executes GraphQL operations against
131
131
  * a local GraphQL schema instead of making network requests. This is commonly
132
- * used for server-side rendering (SSR) and mocking dataa.
132
+ * used for server-side rendering (SSR) and mocking data.
133
133
  *
134
134
  * > [!NOTE]
135
135
  * > While `SchemaLink` can provide GraphQL results on the client, the GraphQL
@@ -2,13 +2,12 @@
2
2
  // Checks the document for errors and throws an exception if there is an error.
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.checkDocument = void 0;
5
- const caches_1 = require("@wry/caches");
6
5
  const graphql_1 = require("graphql");
7
- const optimism_1 = require("optimism");
8
6
  const environment_1 = require("@apollo/client/utilities/environment");
9
7
  const invariant_1 = require("@apollo/client/utilities/invariant");
10
8
  const sizes_js_1 = require("../caching/sizes.cjs");
11
9
  const getOperationName_js_1 = require("./getOperationName.cjs");
10
+ const memoize_js_1 = require("./memoize.cjs");
12
11
  /**
13
12
  * Checks the document for errors and throws an exception if there is an error.
14
13
  *
@@ -16,7 +15,7 @@ const getOperationName_js_1 = require("./getOperationName.cjs");
16
15
  *
17
16
  * @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
18
17
  */
19
- exports.checkDocument = (0, optimism_1.wrap)((doc, expectedType) => {
18
+ exports.checkDocument = (0, memoize_js_1.memoize)((doc, expectedType) => {
20
19
  (0, invariant_1.invariant)(doc && doc.kind === "Document", 1);
21
20
  const operations = doc.definitions.filter((d) => d.kind === "OperationDefinition");
22
21
  if (environment_1.__DEV__) {
@@ -64,6 +63,5 @@ exports.checkDocument = (0, optimism_1.wrap)((doc, expectedType) => {
64
63
  });
65
64
  }, {
66
65
  max: sizes_js_1.cacheSizes["checkDocument"] || 2000 /* defaultCacheSizes["checkDocument"] */,
67
- cache: caches_1.WeakCache,
68
66
  });
69
67
  //# sourceMappingURL=checkDocument.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"checkDocument.cjs","sources":["../../../../src/utilities/internal/checkDocument.ts"],"sourcesContent":["// Checks the document for errors and throws an exception if there is an error.\n\nimport { WeakCache } from \"@wry/caches\";\nimport type { ASTNode } from \"graphql\";\nimport type { DocumentNode, OperationTypeNode } from \"graphql\";\nimport { Kind, visit } from \"graphql\";\nimport { wrap } from \"optimism\";\n\nimport { __DEV__ } from \"@apollo/client/utilities/environment\";\nimport {\n invariant,\n newInvariantError,\n} from \"@apollo/client/utilities/invariant\";\n\nimport { defaultCacheSizes } from \"../../utilities/caching/sizes.js\";\nimport { cacheSizes } from \"../caching/sizes.js\";\n\nimport { getOperationName } from \"./getOperationName.js\";\n\n/**\n * Checks the document for errors and throws an exception if there is an error.\n *\n * @internal\n */\nexport const checkDocument: (\n doc: DocumentNode,\n expectedType?: OperationTypeNode\n) => void = wrap(\n (doc: DocumentNode, expectedType?: OperationTypeNode): void => {\n invariant(\n doc && doc.kind === \"Document\",\n `Expecting a parsed GraphQL document. Perhaps you need to wrap the query \\\nstring in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql`\n );\n const operations = doc.definitions.filter(\n (d) => d.kind === \"OperationDefinition\"\n );\n if (__DEV__) {\n doc.definitions.forEach((definition) => {\n if (\n definition.kind !== \"OperationDefinition\" &&\n definition.kind !== \"FragmentDefinition\"\n ) {\n throw newInvariantError(\n `Schema type definitions not allowed in queries. Found: \"%s\"`,\n definition.kind\n );\n }\n });\n\n invariant(\n operations.length <= 1,\n `Ambiguous GraphQL document: contains %s operations`,\n operations.length\n );\n }\n\n if (expectedType) {\n invariant(\n operations.length == 1 && operations[0].operation === expectedType,\n `Running a %s requires a graphql ` + `%s, but a %s was used instead.`,\n expectedType,\n expectedType,\n operations[0].operation\n );\n }\n\n visit(doc, {\n Field(field, _, __, path) {\n if (\n field.alias &&\n (field.alias.value === \"__typename\" ||\n field.alias.value.startsWith(\"__ac_\")) &&\n field.alias.value !== field.name.value\n ) {\n // not using `invariant` so path calculation only happens in error case\n let current: ASTNode = doc,\n fieldPath: string[] = [];\n for (const key of path) {\n current = (current as any)[key];\n if (current.kind === Kind.FIELD) {\n fieldPath.push(current.alias?.value || current.name.value);\n }\n }\n fieldPath.splice(-1, 1, field.name.value);\n\n throw newInvariantError(\n '`%s` is a forbidden field alias name in the selection set for field `%s` in %s \"%s\".',\n field.alias.value,\n fieldPath.join(\".\"),\n operations[0].operation,\n getOperationName(doc, \"(anonymous)\")\n );\n }\n },\n });\n },\n {\n max: cacheSizes[\"checkDocument\"] || defaultCacheSizes[\"checkDocument\"],\n cache: WeakCache,\n }\n);\n"],"names":[],"mappings":";AAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,C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J,CAAC,EACD;IACE,CAAJ,CAAA,CAAO,EAAE,CAAT,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAmB,CAAC,CAApB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAmC,EAAnC,CAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAA0E;IACtE,CAAJ,CAAA,CAAA,CAAA,CAAS,EAAE,CAAX,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAoB;AACpB,CAAG,CACF;"}
1
+ {"version":3,"file":"checkDocument.cjs","sources":["../../../../src/utilities/internal/checkDocument.ts"],"sourcesContent":["// Checks the document for errors and throws an exception if there is an error.\n\nimport type { ASTNode } from \"graphql\";\nimport type { DocumentNode, OperationTypeNode } from \"graphql\";\nimport { Kind, visit } from \"graphql\";\n\nimport { __DEV__ } from \"@apollo/client/utilities/environment\";\nimport {\n invariant,\n newInvariantError,\n} from \"@apollo/client/utilities/invariant\";\n\nimport { defaultCacheSizes } from \"../../utilities/caching/sizes.js\";\nimport { cacheSizes } from \"../caching/sizes.js\";\n\nimport { getOperationName } from \"./getOperationName.js\";\nimport { memoize } from \"./memoize.js\";\n\n/**\n * Checks the document for errors and throws an exception if there is an error.\n *\n * @internal\n */\nexport const checkDocument: (\n doc: DocumentNode,\n expectedType?: OperationTypeNode\n) => void = memoize(\n (doc: DocumentNode, expectedType?: OperationTypeNode): void => {\n invariant(\n doc && doc.kind === \"Document\",\n `Expecting a parsed GraphQL document. Perhaps you need to wrap the query \\\nstring in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql`\n );\n const operations = doc.definitions.filter(\n (d) => d.kind === \"OperationDefinition\"\n );\n if (__DEV__) {\n doc.definitions.forEach((definition) => {\n if (\n definition.kind !== \"OperationDefinition\" &&\n definition.kind !== \"FragmentDefinition\"\n ) {\n throw newInvariantError(\n `Schema type definitions not allowed in queries. Found: \"%s\"`,\n definition.kind\n );\n }\n });\n\n invariant(\n operations.length <= 1,\n `Ambiguous GraphQL document: contains %s operations`,\n operations.length\n );\n }\n\n if (expectedType) {\n invariant(\n operations.length == 1 && operations[0].operation === expectedType,\n `Running a %s requires a graphql ` + `%s, but a %s was used instead.`,\n expectedType,\n expectedType,\n operations[0].operation\n );\n }\n\n visit(doc, {\n Field(field, _, __, path) {\n if (\n field.alias &&\n (field.alias.value === \"__typename\" ||\n field.alias.value.startsWith(\"__ac_\")) &&\n field.alias.value !== field.name.value\n ) {\n // not using `invariant` so path calculation only happens in error case\n let current: ASTNode = doc,\n fieldPath: string[] = [];\n for (const key of path) {\n current = (current as any)[key];\n if (current.kind === Kind.FIELD) {\n fieldPath.push(current.alias?.value || current.name.value);\n }\n }\n fieldPath.splice(-1, 1, field.name.value);\n\n throw newInvariantError(\n '`%s` is a forbidden field alias name in the selection set for field `%s` in %s \"%s\".',\n field.alias.value,\n fieldPath.join(\".\"),\n operations[0].operation,\n getOperationName(doc, \"(anonymous)\")\n );\n }\n },\n });\n },\n {\n max: cacheSizes[\"checkDocument\"] || defaultCacheSizes[\"checkDocument\"],\n }\n);\n"],"names":[],"mappings":";AAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,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AAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAmC,EAAnC,CAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAA0E;AAC1E,CAAG,CACF;"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.memoize = memoize;
4
+ const trie_1 = require("@wry/trie");
5
+ const caches_js_1 = require("./caches.cjs");
6
+ /**
7
+ * Naive alternative to `wrap` without any dependency tracking, potentially avoiding resulting memory leaks.
8
+ */
9
+ function memoize(fn, { max }) {
10
+ const keys = new trie_1.Trie(true);
11
+ const cache = new caches_js_1.AutoCleanedWeakCache(max);
12
+ return (...args) => {
13
+ const cacheKey = keys.lookupArray(args);
14
+ const cached = cache.get(cacheKey);
15
+ if (cached) {
16
+ if (cached.error) {
17
+ throw cached.error;
18
+ }
19
+ return cached.result;
20
+ }
21
+ const entry = cache.set(cacheKey, {});
22
+ try {
23
+ return (entry.result = fn(...args));
24
+ }
25
+ catch (error) {
26
+ entry.error = error;
27
+ throw error;
28
+ }
29
+ };
30
+ }
31
+ //# sourceMappingURL=memoize.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memoize.cjs","sources":["../../../../src/utilities/internal/memoize.ts"],"sourcesContent":["import { Trie } from \"@wry/trie\";\n\nimport { AutoCleanedWeakCache } from \"./caches.js\";\n\n/**\n * Naive alternative to `wrap` without any dependency tracking, potentially avoiding resulting memory leaks.\n */\nexport function memoize<TArgs extends any[], TResult>(\n fn: (...args: TArgs) => TResult,\n { max }: { max: number }\n): (...args: TArgs) => TResult {\n const keys = new Trie<{}>(true);\n const cache = new AutoCleanedWeakCache<\n {},\n { result?: TResult; error?: unknown }\n >(max);\n\n return (...args: TArgs): TResult => {\n const cacheKey = keys.lookupArray(args);\n const cached = cache.get(cacheKey);\n if (cached) {\n if (cached.error) {\n throw cached.error;\n }\n return cached.result!;\n }\n\n const entry = cache.set(cacheKey, {});\n try {\n return (entry.result = fn(...args));\n } catch (error) {\n entry.error = error;\n throw error;\n }\n };\n}\n"],"names":[],"mappings":";;AAOA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAPA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAEA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,eAAA,CAAA;AAEA,CAAA,CAAA;;CAEA,CAAA;AACA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAgB,CAAhB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAuB,CACrB,CADF,CACiC,EAC/B,EAAE,CAFJ,CAAA,EAAA,CAE0B,EAF1B;IAIE,CAAF,CAAA,CAAA,CAAA,EAAQ,CAAR,CAAA,CAAA,EAAA,EAAe,CAAf,CAAA,EAAmB,CAAnB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAuB,CAAK,CAA5B,CAAA,CAAA,CAAgC,CAAC;IAC/B,CAAF,CAAA,CAAA,CAAA,EAAQ,CAAR,CAAA,CAAA,CAAA,EAA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AAA,CAAA,CAAA,EAAU,CAAV,CAAA,CAAA,CAAA,EAAA,EAAkB,CAAlB,CAAA,CAAA,CAAA,CAAuB,CAAC,CAAxB,CAAA,CAA2B,CAAC,CAA5B,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAoC,EAAE,CAAtC,CAAwC,CAAC;QACrC,CAAJ,CAAA,EAAQ;YACF,CAAN,CAAA,CAAA,CAAA,CAAA,EAAa,CAAC,CAAd,CAAA,CAAA,CAAA,CAAmB,CAAC,CAApB,CAAA,CAAA,CAAA,CAAA,EAAA,EAA6B,CAA7B,CAA+B,CAAC,CAAhC,CAAA,CAAmC,CAAnC,CAAA,CAAA,CAAuC,CAAC,CAAC;QACrC;QAAE,CAAN,CAAA,CAAA,CAAA,EAAA,CAAa,CAAb,CAAA,CAAA,CAAA,CAAkB,EAAE;YACd,CAAN,CAAA,CAAA,CAAA,CAAW,CAAC,CAAZ,CAAA,CAAA,CAAA,EAAA,EAAoB,CAApB,CAAA,CAAA,CAAA,CAAyB;YACnB,CAAN,CAAA,CAAA,CAAA,EAAY,CAAZ,CAAA,CAAA,CAAA,CAAiB;QACb;IACF,CAAC;AACH;"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Naive alternative to `wrap` without any dependency tracking, potentially avoiding resulting memory leaks.
3
+ */
4
+ export declare function memoize<TArgs extends any[], TResult>(fn: (...args: TArgs) => TResult, { max }: {
5
+ max: number;
6
+ }): (...args: TArgs) => TResult;
7
+ //# sourceMappingURL=memoize.d.cts.map
package/__cjs/version.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.build = exports.version = void 0;
4
- exports.version = "4.0.9";
4
+ exports.version = "4.0.10";
5
5
  exports.build = "cjs";
6
6
  //# sourceMappingURL=version.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.cjs","sources":["../../src/version.ts"],"sourcesContent":["export const version = \"local\" as string;\nexport const build = \"source\" as \"source\" | \"esm\" | \"cjs\";\n"],"names":[],"mappings":";;;AAAa,CAAb,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAa,CAAb,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,SAAwC;AAC3B,CAAb,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAa,CAAb,CAAA,CAAA,CAAA,EAAA,OAAyD;"}
1
+ {"version":3,"file":"version.cjs","sources":["../../src/version.ts"],"sourcesContent":["export const version = \"local\" as string;\nexport const build = \"source\" as \"source\" | \"esm\" | \"cjs\";\n"],"names":[],"mappings":";;;AAAa,CAAb,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAa,CAAb,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,UAAwC;AAC3B,CAAb,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAa,CAAb,CAAA,CAAA,CAAA,EAAA,OAAyD;"}
@@ -129,7 +129,7 @@ export declare namespace SchemaLink {
129
129
  /**
130
130
  * `SchemaLink` is a terminating link that executes GraphQL operations against
131
131
  * a local GraphQL schema instead of making network requests. This is commonly
132
- * used for server-side rendering (SSR) and mocking dataa.
132
+ * used for server-side rendering (SSR) and mocking data.
133
133
  *
134
134
  * > [!NOTE]
135
135
  * > While `SchemaLink` can provide GraphQL results on the client, the GraphQL
@@ -4,7 +4,7 @@ import { ApolloLink } from "@apollo/client/link";
4
4
  /**
5
5
  * `SchemaLink` is a terminating link that executes GraphQL operations against
6
6
  * a local GraphQL schema instead of making network requests. This is commonly
7
- * used for server-side rendering (SSR) and mocking dataa.
7
+ * used for server-side rendering (SSR) and mocking data.
8
8
  *
9
9
  * > [!NOTE]
10
10
  * > While `SchemaLink` can provide GraphQL results on the client, the GraphQL
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/link/schema/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5C,O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K;oBACzB,SAAS,EAAE,IAAI,CAAC,SAAS;oBACzB,YAAY,EAAE,OAAO;oBACrB,cAAc,EAAE,SAAS,CAAC,SAAS;oBACnC,aAAa,EAAE,SAAS,CAAC,aAAa;iBACvC,CAAC,CAAC;YACL,CAAC,CAAC;iBACD,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;gBACb,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;oBACrB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;oBACpB,QAAQ,CAAC,QAAQ,EAAE,CAAC;gBACtB,CAAC;YACH,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;gBACf,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;oBACrB,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBACxB,CAAC;YACH,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import type { GraphQLSchema } from \"graphql\";\nimport { execute, validate } from \"graphql\";\nimport { Observable } from \"rxjs\";\n\nimport { ApolloLink } from \"@apollo/client/link\";\n\nexport declare namespace SchemaLink {\n export namespace SchemaLinkDocumentationTypes {\n /**\n * A function that returns the resolver context for a given operation.\n *\n * This function is called for each operation and allows you to create\n * operation-specific context. This is useful when you need to include\n * information from the operation (like headers, variables, etc.) in the\n * resolver context.\n *\n * @param operation - The Apollo Link operation\n * @returns The resolver context object or a promise that resolves to the context\n *\n * @example\n *\n * ```ts\n * const link = new SchemaLink({\n * schema,\n * context: (operation) => {\n * return {\n * userId: operation.getContext().userId,\n * dataSources: {\n * userAPI: new UserAPI(),\n * },\n * };\n * },\n * });\n * ```\n */\n export function ResolverContextFunction(\n operation: ApolloLink.Operation\n ): SchemaLink.ResolverContext | PromiseLike<SchemaLink.ResolverContext>;\n }\n /**\n * The resolver context object passed to GraphQL resolvers.\n *\n * This context object is passed as the third parameter to GraphQL resolvers\n * and typically contains data-fetching connectors, authentication information,\n * and other request-specific data.\n */\n export type ResolverContext = Record<string, any>;\n\n /** {@inheritDoc @apollo/client/link/schema!SchemaLink.SchemaLinkDocumentationTypes.ResolverContextFunction:function(1)} */\n export type ResolverContextFunction = (\n operation: ApolloLink.Operation\n ) => SchemaLink.ResolverContext | PromiseLike<SchemaLink.ResolverContext>;\n\n /**\n * Options for configuring the `SchemaLink`.\n */\n export interface Options {\n /**\n * An executable GraphQL schema to use for operation execution.\n *\n * @remarks\n *\n * This should be a complete, executable GraphQL schema created using\n * tools like `makeExecutableSchema` from `@graphql-tools/schema` or\n * `buildSchema` from `graphql`.\n *\n * @example\n *\n * ```ts\n * import { makeExecutableSchema } from \"@graphql-tools/schema\";\n *\n * const schema = makeExecutableSchema({\n * typeDefs,\n * resolvers,\n * });\n *\n * const link = new SchemaLink({ schema });\n * ```\n */\n schema: GraphQLSchema;\n\n /**\n * The root value passed to root-level resolvers. It's typically not used in\n * most schemas but can be useful for certain advanced patterns.\n */\n rootValue?: any;\n\n /**\n * Context object or function that returns the context object to provide to\n * resolvers. The context is passed as the third parameter to all GraphQL\n * resolvers.\n *\n * - If a static object is provided, the same context will be used for all\n * operations\n * - If a function is provided, the function is called for each operation to\n * generate operation-specific context\n */\n context?: SchemaLink.ResolverContext | SchemaLink.ResolverContextFunction;\n\n /**\n * Whether to validate incoming queries against the schema before execution.\n *\n * When enabled, queries will be validated against the schema before execution,\n * and validation errors will be returned in the result's `errors` array,\n * just like a remote GraphQL server would.\n *\n * This is useful for testing and development to catch query errors early,\n * but may add overhead in production environments.\n *\n * @defaultValue false\n */\n validate?: boolean;\n }\n}\n\n/**\n * `SchemaLink` is a terminating link that executes GraphQL operations against\n * a local GraphQL schema instead of making network requests. This is commonly\n * used for server-side rendering (SSR) and mocking dataa.\n *\n * > [!NOTE]\n * > While `SchemaLink` can provide GraphQL results on the client, the GraphQL\n * > execution layer is [quite large](https://bundlephobia.com/result?p=graphql) for practical client-side use.\n * > For client-side state management, consider Apollo Client's [local state management](https://apollographql.com/docs/react/local-state/local-state-management/)\n * > functionality instead, which integrates with the Apollo Client cache.\n *\n * @example\n *\n * ```ts\n * import { SchemaLink } from \"@apollo/client/link/schema\";\n * import schema from \"./path/to/your/schema\";\n *\n * const link = new SchemaLink({ schema });\n * ```\n */\nexport class SchemaLink extends ApolloLink {\n public schema: SchemaLink.Options[\"schema\"];\n public rootValue: SchemaLink.Options[\"rootValue\"];\n public context: SchemaLink.Options[\"context\"];\n public validate: boolean;\n\n constructor(options: SchemaLink.Options) {\n super();\n this.schema = options.schema;\n this.rootValue = options.rootValue;\n this.context = options.context;\n this.validate = !!options.validate;\n }\n\n public request(\n operation: ApolloLink.Operation\n ): Observable<ApolloLink.Result> {\n return new Observable<ApolloLink.Result>((observer) => {\n new Promise<SchemaLink.ResolverContext>((resolve) =>\n resolve(\n typeof this.context === \"function\" ?\n this.context(operation)\n : this.context\n )\n )\n .then((context) => {\n if (this.validate) {\n const validationErrors = validate(this.schema, operation.query);\n if (validationErrors.length > 0) {\n return { errors: validationErrors };\n }\n }\n\n return execute({\n schema: this.schema,\n document: operation.query,\n rootValue: this.rootValue,\n contextValue: context,\n variableValues: operation.variables,\n operationName: operation.operationName,\n });\n })\n .then((data) => {\n if (!observer.closed) {\n observer.next(data);\n observer.complete();\n }\n })\n .catch((error) => {\n if (!observer.closed) {\n observer.error(error);\n }\n });\n });\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/link/schema/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AA+GjD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,UAAW,SAAQ,UAAU;IACjC,MAAM,CAA+B;IACrC,SAAS,CAAkC;IAC3C,OAAO,CAAgC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,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;oBACrB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;oBACpB,QAAQ,CAAC,QAAQ,EAAE,CAAC;gBACtB,CAAC;YACH,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;gBACf,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;oBACrB,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBACxB,CAAC;YACH,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import type { GraphQLSchema } from \"graphql\";\nimport { execute, validate } from \"graphql\";\nimport { Observable } from \"rxjs\";\n\nimport { ApolloLink } from \"@apollo/client/link\";\n\nexport declare namespace SchemaLink {\n export namespace SchemaLinkDocumentationTypes {\n /**\n * A function that returns the resolver context for a given operation.\n *\n * This function is called for each operation and allows you to create\n * operation-specific context. This is useful when you need to include\n * information from the operation (like headers, variables, etc.) in the\n * resolver context.\n *\n * @param operation - The Apollo Link operation\n * @returns The resolver context object or a promise that resolves to the context\n *\n * @example\n *\n * ```ts\n * const link = new SchemaLink({\n * schema,\n * context: (operation) => {\n * return {\n * userId: operation.getContext().userId,\n * dataSources: {\n * userAPI: new UserAPI(),\n * },\n * };\n * },\n * });\n * ```\n */\n export function ResolverContextFunction(\n operation: ApolloLink.Operation\n ): SchemaLink.ResolverContext | PromiseLike<SchemaLink.ResolverContext>;\n }\n /**\n * The resolver context object passed to GraphQL resolvers.\n *\n * This context object is passed as the third parameter to GraphQL resolvers\n * and typically contains data-fetching connectors, authentication information,\n * and other request-specific data.\n */\n export type ResolverContext = Record<string, any>;\n\n /** {@inheritDoc @apollo/client/link/schema!SchemaLink.SchemaLinkDocumentationTypes.ResolverContextFunction:function(1)} */\n export type ResolverContextFunction = (\n operation: ApolloLink.Operation\n ) => SchemaLink.ResolverContext | PromiseLike<SchemaLink.ResolverContext>;\n\n /**\n * Options for configuring the `SchemaLink`.\n */\n export interface Options {\n /**\n * An executable GraphQL schema to use for operation execution.\n *\n * @remarks\n *\n * This should be a complete, executable GraphQL schema created using\n * tools like `makeExecutableSchema` from `@graphql-tools/schema` or\n * `buildSchema` from `graphql`.\n *\n * @example\n *\n * ```ts\n * import { makeExecutableSchema } from \"@graphql-tools/schema\";\n *\n * const schema = makeExecutableSchema({\n * typeDefs,\n * resolvers,\n * });\n *\n * const link = new SchemaLink({ schema });\n * ```\n */\n schema: GraphQLSchema;\n\n /**\n * The root value passed to root-level resolvers. It's typically not used in\n * most schemas but can be useful for certain advanced patterns.\n */\n rootValue?: any;\n\n /**\n * Context object or function that returns the context object to provide to\n * resolvers. The context is passed as the third parameter to all GraphQL\n * resolvers.\n *\n * - If a static object is provided, the same context will be used for all\n * operations\n * - If a function is provided, the function is called for each operation to\n * generate operation-specific context\n */\n context?: SchemaLink.ResolverContext | SchemaLink.ResolverContextFunction;\n\n /**\n * Whether to validate incoming queries against the schema before execution.\n *\n * When enabled, queries will be validated against the schema before execution,\n * and validation errors will be returned in the result's `errors` array,\n * just like a remote GraphQL server would.\n *\n * This is useful for testing and development to catch query errors early,\n * but may add overhead in production environments.\n *\n * @defaultValue false\n */\n validate?: boolean;\n }\n}\n\n/**\n * `SchemaLink` is a terminating link that executes GraphQL operations against\n * a local GraphQL schema instead of making network requests. This is commonly\n * used for server-side rendering (SSR) and mocking data.\n *\n * > [!NOTE]\n * > While `SchemaLink` can provide GraphQL results on the client, the GraphQL\n * > execution layer is [quite large](https://bundlephobia.com/result?p=graphql) for practical client-side use.\n * > For client-side state management, consider Apollo Client's [local state management](https://apollographql.com/docs/react/local-state/local-state-management/)\n * > functionality instead, which integrates with the Apollo Client cache.\n *\n * @example\n *\n * ```ts\n * import { SchemaLink } from \"@apollo/client/link/schema\";\n * import schema from \"./path/to/your/schema\";\n *\n * const link = new SchemaLink({ schema });\n * ```\n */\nexport class SchemaLink extends ApolloLink {\n public schema: SchemaLink.Options[\"schema\"];\n public rootValue: SchemaLink.Options[\"rootValue\"];\n public context: SchemaLink.Options[\"context\"];\n public validate: boolean;\n\n constructor(options: SchemaLink.Options) {\n super();\n this.schema = options.schema;\n this.rootValue = options.rootValue;\n this.context = options.context;\n this.validate = !!options.validate;\n }\n\n public request(\n operation: ApolloLink.Operation\n ): Observable<ApolloLink.Result> {\n return new Observable<ApolloLink.Result>((observer) => {\n new Promise<SchemaLink.ResolverContext>((resolve) =>\n resolve(\n typeof this.context === \"function\" ?\n this.context(operation)\n : this.context\n )\n )\n .then((context) => {\n if (this.validate) {\n const validationErrors = validate(this.schema, operation.query);\n if (validationErrors.length > 0) {\n return { errors: validationErrors };\n }\n }\n\n return execute({\n schema: this.schema,\n document: operation.query,\n rootValue: this.rootValue,\n contextValue: context,\n variableValues: operation.variables,\n operationName: operation.operationName,\n });\n })\n .then((data) => {\n if (!observer.closed) {\n observer.next(data);\n observer.complete();\n }\n })\n .catch((error) => {\n if (!observer.closed) {\n observer.error(error);\n }\n });\n });\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apollo/client",
3
- "version": "4.0.9",
3
+ "version": "4.0.10",
4
4
  "description": "A fully-featured caching GraphQL client.",
5
5
  "private": false,
6
6
  "keywords": [
@@ -1,11 +1,10 @@
1
1
  // Checks the document for errors and throws an exception if there is an error.
2
- import { WeakCache } from "@wry/caches";
3
2
  import { Kind, visit } from "graphql";
4
- import { wrap } from "optimism";
5
3
  import { __DEV__ } from "@apollo/client/utilities/environment";
6
4
  import { invariant, newInvariantError, } from "@apollo/client/utilities/invariant";
7
5
  import { cacheSizes } from "../caching/sizes.js";
8
6
  import { getOperationName } from "./getOperationName.js";
7
+ import { memoize } from "./memoize.js";
9
8
  /**
10
9
  * Checks the document for errors and throws an exception if there is an error.
11
10
  *
@@ -13,7 +12,7 @@ import { getOperationName } from "./getOperationName.js";
13
12
  *
14
13
  * @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
15
14
  */
16
- export const checkDocument = wrap((doc, expectedType) => {
15
+ export const checkDocument = memoize((doc, expectedType) => {
17
16
  invariant(doc && doc.kind === "Document", 1);
18
17
  const operations = doc.definitions.filter((d) => d.kind === "OperationDefinition");
19
18
  if (__DEV__) {
@@ -61,6 +60,5 @@ export const checkDocument = wrap((doc, expectedType) => {
61
60
  });
62
61
  }, {
63
62
  max: cacheSizes["checkDocument"] || 2000 /* defaultCacheSizes["checkDocument"] */,
64
- cache: WeakCache,
65
63
  });
66
64
  //# sourceMappingURL=checkDocument.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"checkDocument.js","sources":["../../../src/utilities/internal/checkDocument.ts"],"sourcesContent":["// Checks the document for errors and throws an exception if there is an error.\n\nimport { WeakCache } from \"@wry/caches\";\nimport type { ASTNode } from \"graphql\";\nimport type { DocumentNode, OperationTypeNode } from \"graphql\";\nimport { Kind, visit } from \"graphql\";\nimport { wrap } from \"optimism\";\n\nimport { __DEV__ } from \"@apollo/client/utilities/environment\";\nimport {\n invariant,\n newInvariantError,\n} from \"@apollo/client/utilities/invariant\";\n\nimport { defaultCacheSizes } from \"../../utilities/caching/sizes.js\";\nimport { cacheSizes } from \"../caching/sizes.js\";\n\nimport { getOperationName } from \"./getOperationName.js\";\n\n/**\n * Checks the document for errors and throws an exception if there is an error.\n *\n * @internal\n */\nexport const checkDocument: (\n doc: DocumentNode,\n expectedType?: OperationTypeNode\n) => void = wrap(\n (doc: DocumentNode, expectedType?: OperationTypeNode): void => {\n invariant(\n doc && doc.kind === \"Document\",\n `Expecting a parsed GraphQL document. Perhaps you need to wrap the query \\\nstring in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql`\n );\n const operations = doc.definitions.filter(\n (d) => d.kind === \"OperationDefinition\"\n );\n if (__DEV__) {\n doc.definitions.forEach((definition) => {\n if (\n definition.kind !== \"OperationDefinition\" &&\n definition.kind !== \"FragmentDefinition\"\n ) {\n throw newInvariantError(\n `Schema type definitions not allowed in queries. Found: \"%s\"`,\n definition.kind\n );\n }\n });\n\n invariant(\n operations.length <= 1,\n `Ambiguous GraphQL document: contains %s operations`,\n operations.length\n );\n }\n\n if (expectedType) {\n invariant(\n operations.length == 1 && operations[0].operation === expectedType,\n `Running a %s requires a graphql ` + `%s, but a %s was used instead.`,\n expectedType,\n expectedType,\n operations[0].operation\n );\n }\n\n visit(doc, {\n Field(field, _, __, path) {\n if (\n field.alias &&\n (field.alias.value === \"__typename\" ||\n field.alias.value.startsWith(\"__ac_\")) &&\n field.alias.value !== field.name.value\n ) {\n // not using `invariant` so path calculation only happens in error case\n let current: ASTNode = doc,\n fieldPath: string[] = [];\n for (const key of path) {\n current = (current as any)[key];\n if (current.kind === Kind.FIELD) {\n fieldPath.push(current.alias?.value || current.name.value);\n }\n }\n fieldPath.splice(-1, 1, field.name.value);\n\n throw newInvariantError(\n '`%s` is a forbidden field alias name in the selection set for field `%s` in %s \"%s\".',\n field.alias.value,\n fieldPath.join(\".\"),\n operations[0].operation,\n getOperationName(doc, \"(anonymous)\")\n );\n }\n },\n });\n },\n {\n max: cacheSizes[\"checkDocument\"] || defaultCacheSizes[\"checkDocument\"],\n cache: WeakCache,\n }\n);\n"],"names":[],"mappings":"AAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAEA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,EAAE,CAAT,CAAA,CAAA,CAAA,CAAA,CAAA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,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAmC,EAAnC,CAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAA0E;IACtE,CAAJ,CAAA,CAAA,CAAA,CAAS,EAAE,CAAX,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAoB;AACpB,CAAG,CACF;"}
1
+ {"version":3,"file":"checkDocument.js","sources":["../../../src/utilities/internal/checkDocument.ts"],"sourcesContent":["// Checks the document for errors and throws an exception if there is an error.\n\nimport type { ASTNode } from \"graphql\";\nimport type { DocumentNode, OperationTypeNode } from \"graphql\";\nimport { Kind, visit } from \"graphql\";\n\nimport { __DEV__ } from \"@apollo/client/utilities/environment\";\nimport {\n invariant,\n newInvariantError,\n} from \"@apollo/client/utilities/invariant\";\n\nimport { defaultCacheSizes } from \"../../utilities/caching/sizes.js\";\nimport { cacheSizes } from \"../caching/sizes.js\";\n\nimport { getOperationName } from \"./getOperationName.js\";\nimport { memoize } from \"./memoize.js\";\n\n/**\n * Checks the document for errors and throws an exception if there is an error.\n *\n * @internal\n */\nexport const checkDocument: (\n doc: DocumentNode,\n expectedType?: OperationTypeNode\n) => void = memoize(\n (doc: DocumentNode, expectedType?: OperationTypeNode): void => {\n invariant(\n doc && doc.kind === \"Document\",\n `Expecting a parsed GraphQL document. Perhaps you need to wrap the query \\\nstring in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql`\n );\n const operations = doc.definitions.filter(\n (d) => d.kind === \"OperationDefinition\"\n );\n if (__DEV__) {\n doc.definitions.forEach((definition) => {\n if (\n definition.kind !== \"OperationDefinition\" &&\n definition.kind !== \"FragmentDefinition\"\n ) {\n throw newInvariantError(\n `Schema type definitions not allowed in queries. Found: \"%s\"`,\n definition.kind\n );\n }\n });\n\n invariant(\n operations.length <= 1,\n `Ambiguous GraphQL document: contains %s operations`,\n operations.length\n );\n }\n\n if (expectedType) {\n invariant(\n operations.length == 1 && operations[0].operation === expectedType,\n `Running a %s requires a graphql ` + `%s, but a %s was used instead.`,\n expectedType,\n expectedType,\n operations[0].operation\n );\n }\n\n visit(doc, {\n Field(field, _, __, path) {\n if (\n field.alias &&\n (field.alias.value === \"__typename\" ||\n field.alias.value.startsWith(\"__ac_\")) &&\n field.alias.value !== field.name.value\n ) {\n // not using `invariant` so path calculation only happens in error case\n let current: ASTNode = doc,\n fieldPath: string[] = [];\n for (const key of path) {\n current = (current as any)[key];\n if (current.kind === Kind.FIELD) {\n fieldPath.push(current.alias?.value || current.name.value);\n }\n }\n fieldPath.splice(-1, 1, field.name.value);\n\n throw newInvariantError(\n '`%s` is a forbidden field alias name in the selection set for field `%s` in %s \"%s\".',\n field.alias.value,\n fieldPath.join(\".\"),\n operations[0].operation,\n getOperationName(doc, \"(anonymous)\")\n );\n }\n },\n });\n },\n {\n max: cacheSizes[\"checkDocument\"] || defaultCacheSizes[\"checkDocument\"],\n }\n);\n"],"names":[],"mappings":"AAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAIA,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A,CAAmC,EAAnC,CAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAA0E;AAC1E,CAAG,CACF;"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Naive alternative to `wrap` without any dependency tracking, potentially avoiding resulting memory leaks.
3
+ */
4
+ export declare function memoize<TArgs extends any[], TResult>(fn: (...args: TArgs) => TResult, { max }: {
5
+ max: number;
6
+ }): (...args: TArgs) => TResult;
7
+ //# sourceMappingURL=memoize.d.ts.map
@@ -0,0 +1,28 @@
1
+ import { Trie } from "@wry/trie";
2
+ import { AutoCleanedWeakCache } from "./caches.js";
3
+ /**
4
+ * Naive alternative to `wrap` without any dependency tracking, potentially avoiding resulting memory leaks.
5
+ */
6
+ export function memoize(fn, { max }) {
7
+ const keys = new Trie(true);
8
+ const cache = new AutoCleanedWeakCache(max);
9
+ return (...args) => {
10
+ const cacheKey = keys.lookupArray(args);
11
+ const cached = cache.get(cacheKey);
12
+ if (cached) {
13
+ if (cached.error) {
14
+ throw cached.error;
15
+ }
16
+ return cached.result;
17
+ }
18
+ const entry = cache.set(cacheKey, {});
19
+ try {
20
+ return (entry.result = fn(...args));
21
+ }
22
+ catch (error) {
23
+ entry.error = error;
24
+ throw error;
25
+ }
26
+ };
27
+ }
28
+ //# sourceMappingURL=memoize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memoize.js","sourceRoot":"","sources":["../../../src/utilities/internal/memoize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD;;GAEG;AACH,MAAM,UAAU,OAAO,CACrB,EAA+B,EAC/B,EAAE,GAAG,EAAmB;IAExB,MAAM,IAAI,GAAG,IAAI,IAAI,CAAK,IAAI,CAAC,CAAC;IAChC,MAAM,KAAK,GAAG,IAAI,oBAAoB,CAGpC,GAAG,CAAC,CAAC;IAEP,OAAO,CAAC,GAAG,IAAW,EAAW,EAAE;QACjC,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACxC,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACnC,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;gBACjB,MAAM,MAAM,CAAC,KAAK,CAAC;YACrB,CAAC;YACD,OAAO,MAAM,CAAC,MAAO,CAAC;QACxB,CAAC;QAED,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QACtC,IAAI,CAAC;YACH,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QACtC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;YACpB,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { Trie } from \"@wry/trie\";\n\nimport { AutoCleanedWeakCache } from \"./caches.js\";\n\n/**\n * Naive alternative to `wrap` without any dependency tracking, potentially avoiding resulting memory leaks.\n */\nexport function memoize<TArgs extends any[], TResult>(\n fn: (...args: TArgs) => TResult,\n { max }: { max: number }\n): (...args: TArgs) => TResult {\n const keys = new Trie<{}>(true);\n const cache = new AutoCleanedWeakCache<\n {},\n { result?: TResult; error?: unknown }\n >(max);\n\n return (...args: TArgs): TResult => {\n const cacheKey = keys.lookupArray(args);\n const cached = cache.get(cacheKey);\n if (cached) {\n if (cached.error) {\n throw cached.error;\n }\n return cached.result!;\n }\n\n const entry = cache.set(cacheKey, {});\n try {\n return (entry.result = fn(...args));\n } catch (error) {\n entry.error = error;\n throw error;\n }\n };\n}\n"]}
package/version.js CHANGED
@@ -1,3 +1,3 @@
1
- export const version = "4.0.9";
1
+ export const version = "4.0.10";
2
2
  export const build = "esm";
3
3
  //# sourceMappingURL=version.js.map
package/version.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sources":["../src/version.ts"],"sourcesContent":["export const version = \"local\" as string;\nexport const build = \"source\" as \"source\" | \"esm\" | \"cjs\";\n"],"names":[],"mappings":"AAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,CAAP,CAAA,CAAA,CAAA,EAAa,CAAb,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,SAAwC;AACxC,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,CAAP,CAAA,CAAA,CAAA,EAAa,CAAb,CAAA,CAAA,CAAA,EAAA,OAAyD;"}
1
+ {"version":3,"file":"version.js","sources":["../src/version.ts"],"sourcesContent":["export const version = \"local\" as string;\nexport const build = \"source\" as \"source\" | \"esm\" | \"cjs\";\n"],"names":[],"mappings":"AAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,CAAP,CAAA,CAAA,CAAA,EAAa,CAAb,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,UAAwC;AACxC,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,CAAP,CAAA,CAAA,CAAA,EAAa,CAAb,CAAA,CAAA,CAAA,EAAA,OAAyD;"}