@apollo/client 3.7.3 → 3.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -7
- package/apollo-client.cjs +63 -25
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +5 -0
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +6 -1
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +6 -1
- package/core/types.d.ts +2 -1
- package/core/types.d.ts.map +1 -1
- package/core/types.js +1 -0
- package/core/types.js.map +1 -1
- package/core/watchQueryOptions.d.ts +2 -2
- package/core/watchQueryOptions.d.ts.map +1 -1
- package/core/watchQueryOptions.js.map +1 -1
- package/invariantErrorCodes.js +1 -1
- package/link/context/index.d.ts +2 -1
- package/link/context/index.d.ts.map +1 -1
- package/link/context/index.js.map +1 -1
- package/link/core/types.d.ts +5 -4
- package/link/core/types.d.ts.map +1 -1
- package/link/core/types.js.map +1 -1
- package/link/http/createHttpLink.d.ts.map +1 -1
- package/link/http/createHttpLink.js +1 -0
- package/link/http/createHttpLink.js.map +1 -1
- package/link/http/http.cjs +4 -1
- package/link/http/http.cjs.map +1 -1
- package/link/http/http.cjs.native.js +4 -1
- package/link/http/selectHttpOptionsAndBody.d.ts +2 -2
- package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -1
- package/link/http/selectHttpOptionsAndBody.js +3 -1
- package/link/http/selectHttpOptionsAndBody.js.map +1 -1
- package/package.json +19 -15
- package/react/hooks/hooks.cjs +53 -23
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +53 -23
- package/react/hooks/useFragment.d.ts +2 -1
- package/react/hooks/useFragment.d.ts.map +1 -1
- package/react/hooks/useFragment.js +9 -8
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts.map +1 -1
- package/react/hooks/useLazyQuery.js +19 -4
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts.map +1 -1
- package/react/hooks/useMutation.js +7 -7
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +2 -1
- package/react/hooks/useQuery.d.ts.map +1 -1
- package/react/hooks/useQuery.js +19 -5
- package/react/hooks/useQuery.js.map +1 -1
- package/testing/core/core.cjs +17 -0
- package/testing/core/core.cjs.map +1 -1
- package/testing/core/core.cjs.native.js +17 -0
- package/testing/core/index.d.ts +1 -0
- package/testing/core/index.d.ts.map +1 -1
- package/testing/core/index.js +1 -0
- package/testing/core/index.js.map +1 -1
- package/testing/core/wait.d.ts +3 -0
- package/testing/core/wait.d.ts.map +1 -0
- package/testing/core/wait.js +16 -0
- package/testing/core/wait.js.map +1 -0
- package/version.js +1 -1
package/core/core.cjs.native.js
CHANGED
|
@@ -15,7 +15,7 @@ var utils = require('../link/utils');
|
|
|
15
15
|
var tsInvariant = require('ts-invariant');
|
|
16
16
|
var graphqlTag = require('graphql-tag');
|
|
17
17
|
|
|
18
|
-
var version = '3.7.
|
|
18
|
+
var version = '3.7.5';
|
|
19
19
|
|
|
20
20
|
function isNonEmptyArray(value) {
|
|
21
21
|
return Array.isArray(value) && value.length > 0;
|
|
@@ -1938,6 +1938,11 @@ var QueryManager = (function () {
|
|
|
1938
1938
|
onlyRunForcedResolvers: true,
|
|
1939
1939
|
}).then(function (resolved) { return fromData(resolved.data || void 0); });
|
|
1940
1940
|
}
|
|
1941
|
+
if (errorPolicy === 'none' &&
|
|
1942
|
+
networkStatus === exports.NetworkStatus.refetch &&
|
|
1943
|
+
Array.isArray(diff.missing)) {
|
|
1944
|
+
return fromData(void 0);
|
|
1945
|
+
}
|
|
1941
1946
|
return fromData(data);
|
|
1942
1947
|
};
|
|
1943
1948
|
var cacheWriteBehavior = fetchPolicy === "no-cache" ? 0 :
|
package/core/types.d.ts
CHANGED
|
@@ -10,7 +10,8 @@ import { QueryOptions } from './watchQueryOptions';
|
|
|
10
10
|
import { Cache } from '../cache';
|
|
11
11
|
import { IsStrictlyAny } from '../utilities';
|
|
12
12
|
export { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
13
|
-
export
|
|
13
|
+
export interface DefaultContext extends Record<string, any> {
|
|
14
|
+
}
|
|
14
15
|
export declare type QueryListener = (queryInfo: QueryInfo) => void;
|
|
15
16
|
export declare type OnQueryUpdated<TResult> = (observableQuery: ObservableQuery<any>, diff: Cache.DiffResult<any>, lastDiff: Cache.DiffResult<any> | undefined) => boolean | TResult;
|
|
16
17
|
export declare type RefetchQueryDescriptor = string | DocumentNode;
|
package/core/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EA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AG,CAAC,IAC7B,CACF,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,EAC3C,OAAO,EAAE;IACP,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,SAAS,CAAC,EAAE,UAAU,CAAC;CACxB,KACE,IAAI,CAAC;AACV,MAAM,WAAW,SAAS;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG;QACb,CAAE,KAAK,EAAE,MAAM,GAAI,QAAQ,CAAC;KAC7B,CAAC;CACH"}
|
package/core/types.js
CHANGED
package/core/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"","sourcesContent":["import { DocumentNode, GraphQLError } from 'graphql';\n\nimport { ApolloCache } from '../cache';\nimport { FetchResult } from '../link/core';\nimport { ApolloError } from '../errors';\nimport { QueryInfo } from './QueryInfo';\nimport { NetworkStatus } from './networkStatus';\nimport { Resolver } from './LocalState';\nimport { ObservableQuery } from './ObservableQuery';\nimport { QueryOptions } from './watchQueryOptions';\nimport { Cache } from '../cache';\nimport { IsStrictlyAny } from '../utilities';\n\nexport { TypedDocumentNode } from '@graphql-typed-document-node/core';\n\nexport
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAe8D,CAAC","sourcesContent":["import { DocumentNode, GraphQLError } from 'graphql';\n\nimport { ApolloCache } from '../cache';\nimport { FetchResult } from '../link/core';\nimport { ApolloError } from '../errors';\nimport { QueryInfo } from './QueryInfo';\nimport { NetworkStatus } from './networkStatus';\nimport { Resolver } from './LocalState';\nimport { ObservableQuery } from './ObservableQuery';\nimport { QueryOptions } from './watchQueryOptions';\nimport { Cache } from '../cache';\nimport { IsStrictlyAny } from '../utilities';\n\nexport { TypedDocumentNode } from '@graphql-typed-document-node/core';\n\nexport interface DefaultContext extends Record<string, any> {};\n\nexport type QueryListener = (queryInfo: QueryInfo) => void;\n\nexport type OnQueryUpdated<TResult> = (\n observableQuery: ObservableQuery<any>,\n diff: Cache.DiffResult<any>,\n lastDiff: Cache.DiffResult<any> | undefined,\n) => boolean | TResult;\n\nexport type RefetchQueryDescriptor = string | DocumentNode;\nexport type InternalRefetchQueryDescriptor = RefetchQueryDescriptor | QueryOptions;\n\ntype RefetchQueriesIncludeShorthand = \"all\" | \"active\";\n\nexport type RefetchQueriesInclude =\n | RefetchQueryDescriptor[]\n | RefetchQueriesIncludeShorthand;\n\nexport type InternalRefetchQueriesInclude =\n | InternalRefetchQueryDescriptor[]\n | RefetchQueriesIncludeShorthand;\n\n// Used by ApolloClient[\"refetchQueries\"]\n// TODO Improve documentation comments for this public type.\nexport interface RefetchQueriesOptions<\n TCache extends ApolloCache<any>,\n TResult,\n> {\n updateCache?: (cache: TCache) => void;\n // The client.refetchQueries method discourages passing QueryOptions, by\n // restricting the public type of options.include to exclude QueryOptions as\n // an available array element type (see InternalRefetchQueriesInclude for a\n // version of RefetchQueriesInclude that allows legacy QueryOptions objects).\n include?: RefetchQueriesInclude;\n optimistic?: boolean;\n // If no onQueryUpdated function is provided, any queries affected by the\n // updateCache function or included in the options.include array will be\n // refetched by default. Passing null instead of undefined disables this\n // default refetching behavior for affected queries, though included queries\n // will still be refetched.\n onQueryUpdated?: OnQueryUpdated<TResult> | null;\n}\n\n// The client.refetchQueries method returns a thenable (PromiseLike) object\n// whose result is an array of Promise.resolve'd TResult values, where TResult\n// is whatever type the (optional) onQueryUpdated function returns. When no\n// onQueryUpdated function is given, TResult defaults to ApolloQueryResult<any>\n// (thanks to default type parameters for client.refetchQueries).\nexport type RefetchQueriesPromiseResults<TResult> =\n // If onQueryUpdated returns any, all bets are off, so the results array must\n // be a generic any[] array, which is much less confusing than the union type\n // we get if we don't check for any. I hoped `any extends TResult` would do\n // the trick here, instead of IsStrictlyAny, but you can see for yourself what\n // fails in the refetchQueries tests if you try making that simplification.\n IsStrictlyAny<TResult> extends true ? any[] :\n // If the onQueryUpdated function passed to client.refetchQueries returns true\n // or false, that means either to refetch the query (true) or to skip the\n // query (false). Since refetching produces an ApolloQueryResult<any>, and\n // skipping produces nothing, the fully-resolved array of all results produced\n // will be an ApolloQueryResult<any>[], when TResult extends boolean.\n TResult extends boolean ? ApolloQueryResult<any>[] :\n // If onQueryUpdated returns a PromiseLike<U>, that thenable will be passed as\n // an array element to Promise.all, so we infer/unwrap the array type U here.\n TResult extends PromiseLike<infer U> ? U[] :\n // All other onQueryUpdated results end up in the final Promise.all array as\n // themselves, with their original TResult type. Note that TResult will\n // default to ApolloQueryResult<any> if no onQueryUpdated function is passed\n // to client.refetchQueries.\n TResult[];\n\n// The result of client.refetchQueries is thenable/awaitable, if you just want\n// an array of fully resolved results, but you can also access the raw results\n// immediately by examining the additional { queries, results } properties of\n// the RefetchQueriesResult<TResult> object.\nexport interface RefetchQueriesResult<TResult>\nextends Promise<RefetchQueriesPromiseResults<TResult>> {\n // An array of ObservableQuery objects corresponding 1:1 to TResult values\n // in the results arrays (both the TResult[] array below, and the results\n // array resolved by the Promise above).\n queries: ObservableQuery<any>[];\n // These are the raw TResult values returned by any onQueryUpdated functions\n // that were invoked by client.refetchQueries.\n results: InternalRefetchQueriesResult<TResult>[];\n}\n\n// Used by QueryManager[\"refetchQueries\"]\nexport interface InternalRefetchQueriesOptions<\n TCache extends ApolloCache<any>,\n TResult,\n> extends Omit<RefetchQueriesOptions<TCache, TResult>, \"include\"> {\n // Just like the refetchQueries option for a mutation, an array of strings,\n // DocumentNode objects, and/or QueryOptions objects, or one of the shorthand\n // strings \"all\" or \"active\", to select every (active) query.\n include?: InternalRefetchQueriesInclude;\n // This part of the API is a (useful) implementation detail, but need not be\n // exposed in the public client.refetchQueries API (above).\n removeOptimistic?: string;\n}\n\nexport type InternalRefetchQueriesResult<TResult> =\n // If onQueryUpdated returns a boolean, that's equivalent to refetching the\n // query when the boolean is true and skipping the query when false, so the\n // internal type of refetched results is Promise<ApolloQueryResult<any>>.\n TResult extends boolean ? Promise<ApolloQueryResult<any>> :\n // Otherwise, onQueryUpdated returns whatever it returns. If onQueryUpdated is\n // not provided, TResult defaults to Promise<ApolloQueryResult<any>> (see the\n // generic type parameters of client.refetchQueries).\n TResult;\n\nexport type InternalRefetchQueriesMap<TResult> =\n Map<ObservableQuery<any>,\n InternalRefetchQueriesResult<TResult>>;\n\n// TODO Remove this unnecessary type in Apollo Client 4.\nexport type { QueryOptions as PureQueryOptions };\n\nexport type OperationVariables = Record<string, any>;\n\nexport type ApolloQueryResult<T> = {\n data: T;\n /**\n * A list of any errors that occurred during server-side execution of a GraphQL operation.\n * See https://www.apollographql.com/docs/react/data/error-handling/ for more information.\n */\n errors?: ReadonlyArray<GraphQLError>;\n /**\n * The single Error object that is passed to onError and useQuery hooks, and is often thrown during manual `client.query` calls.\n * This will contain both a NetworkError field and any GraphQLErrors.\n * See https://www.apollographql.com/docs/react/data/error-handling/ for more information.\n */\n error?: ApolloError;\n loading: boolean;\n networkStatus: NetworkStatus;\n // If result.data was read from the cache with missing fields,\n // result.partial will be true. Otherwise, result.partial will be falsy\n // (usually because the property is absent from the result object).\n partial?: boolean;\n};\n\n// This is part of the public API, people write these functions in `updateQueries`.\nexport type MutationQueryReducer<T> = (\n previousResult: Record<string, any>,\n options: {\n mutationResult: FetchResult<T>;\n queryName: string | undefined;\n queryVariables: Record<string, any>;\n },\n) => Record<string, any>;\n\nexport type MutationQueryReducersMap<T = { [key: string]: any }> = {\n [queryName: string]: MutationQueryReducer<T>;\n};\n\n// @deprecated Use MutationUpdaterFunction instead.\nexport type MutationUpdaterFn<T = { [key: string]: any }> = (\n // The MutationUpdaterFn type is broken because it mistakenly uses the same\n // type parameter T for both the cache and the mutationResult. Do not use this\n // type unless you absolutely need it for backwards compatibility.\n cache: ApolloCache<T>,\n mutationResult: FetchResult<T>,\n) => void;\n\nexport type MutationUpdaterFunction<\n TData,\n TVariables,\n TContext,\n TCache extends ApolloCache<any>\n> = (\n cache: TCache,\n result: Omit<FetchResult<TData>, 'context'>,\n options: {\n context?: TContext,\n variables?: TVariables,\n },\n) => void;\nexport interface Resolvers {\n [key: string]: {\n [ field: string ]: Resolver;\n };\n}\n"]}
|
|
@@ -13,7 +13,7 @@ export interface QueryOptions<TVariables = OperationVariables, TData = any> {
|
|
|
13
13
|
query: DocumentNode | TypedDocumentNode<TData, TVariables>;
|
|
14
14
|
variables?: TVariables;
|
|
15
15
|
errorPolicy?: ErrorPolicy;
|
|
16
|
-
context?:
|
|
16
|
+
context?: DefaultContext;
|
|
17
17
|
fetchPolicy?: FetchPolicy;
|
|
18
18
|
pollInterval?: number;
|
|
19
19
|
notifyOnNetworkStatusChange?: boolean;
|
|
@@ -36,7 +36,7 @@ export interface NextFetchPolicyContext<TData, TVariables> {
|
|
|
36
36
|
export interface FetchMoreQueryOptions<TVariables, TData = any> {
|
|
37
37
|
query?: DocumentNode | TypedDocumentNode<TData, TVariables>;
|
|
38
38
|
variables?: Partial<TVariables>;
|
|
39
|
-
context?:
|
|
39
|
+
context?: DefaultContext;
|
|
40
40
|
}
|
|
41
41
|
export declare type UpdateQueryFn<TData = any, TSubscriptionVariables = OperationVariables, TSubscriptionData = TData> = (previousQueryResult: TData, options: {
|
|
42
42
|
subscriptionData: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watchQueryOptions.d.ts","sourceRoot":"","sources":["../../src/core/watchQueryOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,EACd,6BAA6B,EAC9B,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;A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M,CAAC;IAKhE,QAAQ,EAAE,YAAY,GAAG,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAO9D,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAWlC,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watchQueryOptions.js","sourceRoot":"","sources":["../../src/core/watchQueryOptions.ts"],"names":[],"mappings":"","sourcesContent":["import { DocumentNode } from 'graphql';\nimport { TypedDocumentNode } from '@graphql-typed-document-node/core';\n\nimport { FetchResult } from '../link/core';\nimport {\n DefaultContext,\n MutationQueryReducersMap,\n OperationVariables,\n MutationUpdaterFunction,\n OnQueryUpdated,\n InternalRefetchQueriesInclude,\n} from './types';\nimport { ApolloCache } from '../cache';\nimport { ObservableQuery } from './ObservableQuery';\n\n/**\n * fetchPolicy determines where the client may return a result from. The options are:\n * - cache-first (default): return result from cache. Only fetch from network if cached result is not available.\n * - cache-and-network: return result from cache first (if it exists), then return network result once it's available.\n * - cache-only: return result from cache if available, fail otherwise.\n * - no-cache: return result from network, fail if network call doesn't succeed, don't save to cache\n * - network-only: return result from network, fail if network call doesn't succeed, save to cache\n * - standby: only for queries that aren't actively watched, but should be available for refetch and updateQueries.\n */\nexport type FetchPolicy =\n | 'cache-first'\n | 'network-only'\n | 'cache-only'\n | 'no-cache'\n | 'standby';\n\nexport type WatchQueryFetchPolicy = FetchPolicy | 'cache-and-network';\n\nexport type MutationFetchPolicy = Extract<\n FetchPolicy,\n | 'network-only' // default behavior (mutation results written to cache)\n | 'no-cache' // alternate behavior (results not written to cache)\n>;\n\nexport type RefetchWritePolicy = \"merge\" | \"overwrite\";\n\n/**\n * errorPolicy determines the level of events for errors in the execution result. The options are:\n * - none (default): any errors from the request are treated like runtime errors and the observable is stopped (XXX this is default to lower breaking changes going from AC 1.0 => 2.0)\n * - ignore: errors from the request do not stop the observable, but also don't call `next`\n * - all: errors are treated like data and will notify observables\n */\nexport type ErrorPolicy = 'none' | 'ignore' | 'all';\n\n/**\n * Query options.\n */\nexport interface QueryOptions<TVariables = OperationVariables, TData = any> {\n /**\n * A GraphQL document that consists of a single query to be sent down to the\n * server.\n */\n // TODO REFACTOR: rename this to document. Didn't do it yet because it's in a\n // lot of tests.\n query: DocumentNode | TypedDocumentNode<TData, TVariables>;\n\n /**\n * A map going from variable name to variable value, where the variables are used\n * within the GraphQL query.\n */\n variables?: TVariables;\n\n /**\n * Specifies the {@link ErrorPolicy} to be used for this query\n */\n errorPolicy?: ErrorPolicy;\n\n /**\n * Context to be passed to link execution chain\n */\n context?: any;\n\n /**\n * Specifies the {@link FetchPolicy} to be used for this query\n */\n fetchPolicy?: FetchPolicy;\n\n /**\n * The time interval (in milliseconds) on which this query should be\n * refetched from the server.\n */\n pollInterval?: number;\n\n /**\n * Whether or not updates to the network status should trigger next on the observer of this query\n */\n notifyOnNetworkStatusChange?: boolean;\n\n /**\n * Allow returning incomplete data from the cache when a larger query cannot\n * be fully satisfied by the cache, instead of returning nothing.\n */\n returnPartialData?: boolean;\n\n /**\n * If `true`, perform a query `refetch` if the query result is marked as\n * being partial, and the returned data is reset to an empty Object by the\n * Apollo Client `QueryManager` (due to a cache miss).\n */\n partialRefetch?: boolean;\n\n /**\n * Whether to canonize cache results before returning them. Canonization\n * takes some extra time, but it speeds up future deep equality comparisons.\n * Defaults to false.\n */\n canonizeResults?: boolean;\n}\n\n/**\n * Watched query options.\n */\nexport interface WatchQueryOptions<TVariables = OperationVariables, TData = any>\n extends Omit<QueryOptions<TVariables, TData>, 'fetchPolicy'> {\n /**\n * Specifies the {@link FetchPolicy} to be used for this query.\n */\n fetchPolicy?: WatchQueryFetchPolicy;\n\n /**\n * Specifies the {@link FetchPolicy} to be used after this query has completed.\n */\n nextFetchPolicy?: WatchQueryFetchPolicy | ((\n this: WatchQueryOptions<TVariables, TData>,\n currentFetchPolicy: WatchQueryFetchPolicy,\n context: NextFetchPolicyContext<TData, TVariables>,\n ) => WatchQueryFetchPolicy);\n\n /**\n * Defaults to the initial value of options.fetchPolicy, but can be explicitly\n * configured to specify the WatchQueryFetchPolicy to revert back to whenever\n * variables change (unless nextFetchPolicy intervenes).\n */\n initialFetchPolicy?: WatchQueryFetchPolicy;\n\n /**\n * Specifies whether a {@link NetworkStatus.refetch} operation should merge\n * incoming field data with existing data, or overwrite the existing data.\n * Overwriting is probably preferable, but merging is currently the default\n * behavior, for backwards compatibility with Apollo Client 3.x.\n */\n refetchWritePolicy?: RefetchWritePolicy;\n}\n\nexport interface NextFetchPolicyContext<TData, TVariables> {\n reason:\n | \"after-fetch\"\n | \"variables-changed\";\n observable: ObservableQuery<TData, TVariables>;\n options: WatchQueryOptions<TVariables, TData>;\n initialFetchPolicy: WatchQueryFetchPolicy;\n}\n\nexport interface FetchMoreQueryOptions<TVariables, TData = any> {\n query?: DocumentNode | TypedDocumentNode<TData, TVariables>;\n variables?: Partial<TVariables>;\n context?: any;\n}\n\nexport type UpdateQueryFn<\n TData = any,\n TSubscriptionVariables = OperationVariables,\n TSubscriptionData = TData\n> = (\n previousQueryResult: TData,\n options: {\n subscriptionData: { data: TSubscriptionData };\n variables?: TSubscriptionVariables;\n },\n) => TData;\n\nexport type SubscribeToMoreOptions<\n TData = any,\n TSubscriptionVariables = OperationVariables,\n TSubscriptionData = TData\n> = {\n document: DocumentNode | TypedDocumentNode<TSubscriptionData, TSubscriptionVariables>;\n variables?: TSubscriptionVariables;\n updateQuery?: UpdateQueryFn<TData, TSubscriptionVariables, TSubscriptionData>;\n onError?: (error: Error) => void;\n context?: DefaultContext;\n};\n\nexport interface SubscriptionOptions<TVariables = OperationVariables, TData = any> {\n /**\n * A GraphQL document, often created with `gql` from the `graphql-tag`\n * package, that contains a single subscription inside of it.\n */\n query: DocumentNode | TypedDocumentNode<TData, TVariables>;\n\n /**\n * An object that maps from the name of a variable as used in the subscription\n * GraphQL document to that variable's value.\n */\n variables?: TVariables;\n\n /**\n * Specifies the {@link FetchPolicy} to be used for this subscription.\n */\n fetchPolicy?: FetchPolicy;\n\n /**\n * Specifies the {@link ErrorPolicy} to be used for this operation\n */\n errorPolicy?: ErrorPolicy;\n\n /**\n * Context object to be passed through the link execution chain.\n */\n context?: DefaultContext;\n}\n\nexport interface MutationBaseOptions<\n TData = any,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n> {\n /**\n * An object that represents the result of this mutation that will be\n * optimistically stored before the server has actually returned a result.\n * This is most often used for optimistic UI, where we want to be able to see\n * the result of a mutation immediately, and update the UI later if any errors\n * appear.\n */\n optimisticResponse?: TData | ((vars: TVariables) => TData);\n\n /**\n * A {@link MutationQueryReducersMap}, which is map from query names to\n * mutation query reducers. Briefly, this map defines how to incorporate the\n * results of the mutation into the results of queries that are currently\n * being watched by your application.\n */\n updateQueries?: MutationQueryReducersMap<TData>;\n\n /**\n * A list of query names which will be refetched once this mutation has\n * returned. This is often used if you have a set of queries which may be\n * affected by a mutation and will have to update. Rather than writing a\n * mutation query reducer (i.e. `updateQueries`) for this, you can simply\n * refetch the queries that will be affected and achieve a consistent store\n * once these queries return.\n */\n refetchQueries?:\n | ((result: FetchResult<TData>) => InternalRefetchQueriesInclude)\n | InternalRefetchQueriesInclude;\n\n /**\n * By default, `refetchQueries` does not wait for the refetched queries to\n * be completed, before resolving the mutation `Promise`. This ensures that\n * query refetching does not hold up mutation response handling (query\n * refetching is handled asynchronously). Set `awaitRefetchQueries` to\n * `true` if you would like to wait for the refetched queries to complete,\n * before the mutation can be marked as resolved.\n */\n awaitRefetchQueries?: boolean;\n\n /**\n * A function which provides an {@link ApolloCache} instance, and the result\n * of the mutation, to allow the user to update the store based on the\n * results of the mutation.\n *\n * This function will be called twice over the lifecycle of a mutation. Once\n * at the very beginning if an `optimisticResponse` was provided. The writes\n * created from the optimistic data will be rolled back before the second time\n * this function is called which is when the mutation has successfully\n * resolved. At that point `update` will be called with the *actual* mutation\n * result and those writes will not be rolled back.\n *\n * Note that since this function is intended to be used to update the\n * store, it cannot be used with a `no-cache` fetch policy. If you're\n * interested in performing some action after a mutation has completed,\n * and you don't need to update the store, use the Promise returned from\n * `client.mutate` instead.\n */\n update?: MutationUpdaterFunction<TData, TVariables, TContext, TCache>;\n\n /**\n * A function that will be called for each ObservableQuery affected by\n * this mutation, after the mutation has completed.\n */\n onQueryUpdated?: OnQueryUpdated<any>;\n\n /**\n * Specifies the {@link ErrorPolicy} to be used for this operation\n */\n errorPolicy?: ErrorPolicy;\n\n /**\n * An object that maps from the name of a variable as used in the mutation\n * GraphQL document to that variable's value.\n */\n variables?: TVariables;\n\n /**\n * The context to be passed to the link execution chain. This context will\n * only be used with this mutation. It will not be used with\n * `refetchQueries`. Refetched queries use the context they were\n * initialized with (since the initial context is stored as part of the\n * `ObservableQuery` instance). If a specific context is needed when\n * refetching queries, make sure it is configured (via the\n * [query `context` option](https://www.apollographql.com/docs/react/api/apollo-client#ApolloClient.query))\n * when the query is first initialized/run.\n */\n context?: TContext;\n}\n\nexport interface MutationOptions<\n TData = any,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n> extends MutationBaseOptions<TData, TVariables, TContext, TCache> {\n /**\n * A GraphQL document, often created with `gql` from the `graphql-tag`\n * package, that contains a single mutation inside of it.\n */\n mutation: DocumentNode | TypedDocumentNode<TData, TVariables>;\n\n /**\n * Specifies the {@link MutationFetchPolicy} to be used for this query.\n * Mutations support only 'network-only' and 'no-cache' fetchPolicy strings.\n * If fetchPolicy is not provided, it defaults to 'network-only'.\n */\n fetchPolicy?: MutationFetchPolicy;\n\n /**\n * To avoid retaining sensitive information from mutation root field\n * arguments, Apollo Client v3.4+ automatically clears any `ROOT_MUTATION`\n * fields from the cache after each mutation finishes. If you need this\n * information to remain in the cache, you can prevent the removal by passing\n * `keepRootFields: true` to the mutation. `ROOT_MUTATION` result data are\n * also passed to the mutation `update` function, so we recommend obtaining\n * the results that way, rather than using this option, if possible.\n */\n keepRootFields?: boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"watchQueryOptions.js","sourceRoot":"","sources":["../../src/core/watchQueryOptions.ts"],"names":[],"mappings":"","sourcesContent":["import { DocumentNode } from 'graphql';\nimport { TypedDocumentNode } from '@graphql-typed-document-node/core';\n\nimport { FetchResult } from '../link/core';\nimport {\n DefaultContext,\n MutationQueryReducersMap,\n OperationVariables,\n MutationUpdaterFunction,\n OnQueryUpdated,\n InternalRefetchQueriesInclude,\n} from './types';\nimport { ApolloCache } from '../cache';\nimport { ObservableQuery } from './ObservableQuery';\n\n/**\n * fetchPolicy determines where the client may return a result from. The options are:\n * - cache-first (default): return result from cache. Only fetch from network if cached result is not available.\n * - cache-and-network: return result from cache first (if it exists), then return network result once it's available.\n * - cache-only: return result from cache if available, fail otherwise.\n * - no-cache: return result from network, fail if network call doesn't succeed, don't save to cache\n * - network-only: return result from network, fail if network call doesn't succeed, save to cache\n * - standby: only for queries that aren't actively watched, but should be available for refetch and updateQueries.\n */\nexport type FetchPolicy =\n | 'cache-first'\n | 'network-only'\n | 'cache-only'\n | 'no-cache'\n | 'standby';\n\nexport type WatchQueryFetchPolicy = FetchPolicy | 'cache-and-network';\n\nexport type MutationFetchPolicy = Extract<\n FetchPolicy,\n | 'network-only' // default behavior (mutation results written to cache)\n | 'no-cache' // alternate behavior (results not written to cache)\n>;\n\nexport type RefetchWritePolicy = \"merge\" | \"overwrite\";\n\n/**\n * errorPolicy determines the level of events for errors in the execution result. The options are:\n * - none (default): any errors from the request are treated like runtime errors and the observable is stopped (XXX this is default to lower breaking changes going from AC 1.0 => 2.0)\n * - ignore: errors from the request do not stop the observable, but also don't call `next`\n * - all: errors are treated like data and will notify observables\n */\nexport type ErrorPolicy = 'none' | 'ignore' | 'all';\n\n/**\n * Query options.\n */\nexport interface QueryOptions<TVariables = OperationVariables, TData = any> {\n /**\n * A GraphQL document that consists of a single query to be sent down to the\n * server.\n */\n // TODO REFACTOR: rename this to document. Didn't do it yet because it's in a\n // lot of tests.\n query: DocumentNode | TypedDocumentNode<TData, TVariables>;\n\n /**\n * A map going from variable name to variable value, where the variables are used\n * within the GraphQL query.\n */\n variables?: TVariables;\n\n /**\n * Specifies the {@link ErrorPolicy} to be used for this query\n */\n errorPolicy?: ErrorPolicy;\n\n /**\n * Context to be passed to link execution chain\n */\n context?: DefaultContext;\n\n /**\n * Specifies the {@link FetchPolicy} to be used for this query\n */\n fetchPolicy?: FetchPolicy;\n\n /**\n * The time interval (in milliseconds) on which this query should be\n * refetched from the server.\n */\n pollInterval?: number;\n\n /**\n * Whether or not updates to the network status should trigger next on the observer of this query\n */\n notifyOnNetworkStatusChange?: boolean;\n\n /**\n * Allow returning incomplete data from the cache when a larger query cannot\n * be fully satisfied by the cache, instead of returning nothing.\n */\n returnPartialData?: boolean;\n\n /**\n * If `true`, perform a query `refetch` if the query result is marked as\n * being partial, and the returned data is reset to an empty Object by the\n * Apollo Client `QueryManager` (due to a cache miss).\n */\n partialRefetch?: boolean;\n\n /**\n * Whether to canonize cache results before returning them. Canonization\n * takes some extra time, but it speeds up future deep equality comparisons.\n * Defaults to false.\n */\n canonizeResults?: boolean;\n}\n\n/**\n * Watched query options.\n */\nexport interface WatchQueryOptions<TVariables = OperationVariables, TData = any>\n extends Omit<QueryOptions<TVariables, TData>, 'fetchPolicy'> {\n /**\n * Specifies the {@link FetchPolicy} to be used for this query.\n */\n fetchPolicy?: WatchQueryFetchPolicy;\n\n /**\n * Specifies the {@link FetchPolicy} to be used after this query has completed.\n */\n nextFetchPolicy?: WatchQueryFetchPolicy | ((\n this: WatchQueryOptions<TVariables, TData>,\n currentFetchPolicy: WatchQueryFetchPolicy,\n context: NextFetchPolicyContext<TData, TVariables>,\n ) => WatchQueryFetchPolicy);\n\n /**\n * Defaults to the initial value of options.fetchPolicy, but can be explicitly\n * configured to specify the WatchQueryFetchPolicy to revert back to whenever\n * variables change (unless nextFetchPolicy intervenes).\n */\n initialFetchPolicy?: WatchQueryFetchPolicy;\n\n /**\n * Specifies whether a {@link NetworkStatus.refetch} operation should merge\n * incoming field data with existing data, or overwrite the existing data.\n * Overwriting is probably preferable, but merging is currently the default\n * behavior, for backwards compatibility with Apollo Client 3.x.\n */\n refetchWritePolicy?: RefetchWritePolicy;\n}\n\nexport interface NextFetchPolicyContext<TData, TVariables> {\n reason:\n | \"after-fetch\"\n | \"variables-changed\";\n observable: ObservableQuery<TData, TVariables>;\n options: WatchQueryOptions<TVariables, TData>;\n initialFetchPolicy: WatchQueryFetchPolicy;\n}\n\nexport interface FetchMoreQueryOptions<TVariables, TData = any> {\n query?: DocumentNode | TypedDocumentNode<TData, TVariables>;\n variables?: Partial<TVariables>;\n context?: DefaultContext;\n}\n\nexport type UpdateQueryFn<\n TData = any,\n TSubscriptionVariables = OperationVariables,\n TSubscriptionData = TData\n> = (\n previousQueryResult: TData,\n options: {\n subscriptionData: { data: TSubscriptionData };\n variables?: TSubscriptionVariables;\n },\n) => TData;\n\nexport type SubscribeToMoreOptions<\n TData = any,\n TSubscriptionVariables = OperationVariables,\n TSubscriptionData = TData\n> = {\n document: DocumentNode | TypedDocumentNode<TSubscriptionData, TSubscriptionVariables>;\n variables?: TSubscriptionVariables;\n updateQuery?: UpdateQueryFn<TData, TSubscriptionVariables, TSubscriptionData>;\n onError?: (error: Error) => void;\n context?: DefaultContext;\n};\n\nexport interface SubscriptionOptions<TVariables = OperationVariables, TData = any> {\n /**\n * A GraphQL document, often created with `gql` from the `graphql-tag`\n * package, that contains a single subscription inside of it.\n */\n query: DocumentNode | TypedDocumentNode<TData, TVariables>;\n\n /**\n * An object that maps from the name of a variable as used in the subscription\n * GraphQL document to that variable's value.\n */\n variables?: TVariables;\n\n /**\n * Specifies the {@link FetchPolicy} to be used for this subscription.\n */\n fetchPolicy?: FetchPolicy;\n\n /**\n * Specifies the {@link ErrorPolicy} to be used for this operation\n */\n errorPolicy?: ErrorPolicy;\n\n /**\n * Context object to be passed through the link execution chain.\n */\n context?: DefaultContext;\n}\n\nexport interface MutationBaseOptions<\n TData = any,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n> {\n /**\n * An object that represents the result of this mutation that will be\n * optimistically stored before the server has actually returned a result.\n * This is most often used for optimistic UI, where we want to be able to see\n * the result of a mutation immediately, and update the UI later if any errors\n * appear.\n */\n optimisticResponse?: TData | ((vars: TVariables) => TData);\n\n /**\n * A {@link MutationQueryReducersMap}, which is map from query names to\n * mutation query reducers. Briefly, this map defines how to incorporate the\n * results of the mutation into the results of queries that are currently\n * being watched by your application.\n */\n updateQueries?: MutationQueryReducersMap<TData>;\n\n /**\n * A list of query names which will be refetched once this mutation has\n * returned. This is often used if you have a set of queries which may be\n * affected by a mutation and will have to update. Rather than writing a\n * mutation query reducer (i.e. `updateQueries`) for this, you can simply\n * refetch the queries that will be affected and achieve a consistent store\n * once these queries return.\n */\n refetchQueries?:\n | ((result: FetchResult<TData>) => InternalRefetchQueriesInclude)\n | InternalRefetchQueriesInclude;\n\n /**\n * By default, `refetchQueries` does not wait for the refetched queries to\n * be completed, before resolving the mutation `Promise`. This ensures that\n * query refetching does not hold up mutation response handling (query\n * refetching is handled asynchronously). Set `awaitRefetchQueries` to\n * `true` if you would like to wait for the refetched queries to complete,\n * before the mutation can be marked as resolved.\n */\n awaitRefetchQueries?: boolean;\n\n /**\n * A function which provides an {@link ApolloCache} instance, and the result\n * of the mutation, to allow the user to update the store based on the\n * results of the mutation.\n *\n * This function will be called twice over the lifecycle of a mutation. Once\n * at the very beginning if an `optimisticResponse` was provided. The writes\n * created from the optimistic data will be rolled back before the second time\n * this function is called which is when the mutation has successfully\n * resolved. At that point `update` will be called with the *actual* mutation\n * result and those writes will not be rolled back.\n *\n * Note that since this function is intended to be used to update the\n * store, it cannot be used with a `no-cache` fetch policy. If you're\n * interested in performing some action after a mutation has completed,\n * and you don't need to update the store, use the Promise returned from\n * `client.mutate` instead.\n */\n update?: MutationUpdaterFunction<TData, TVariables, TContext, TCache>;\n\n /**\n * A function that will be called for each ObservableQuery affected by\n * this mutation, after the mutation has completed.\n */\n onQueryUpdated?: OnQueryUpdated<any>;\n\n /**\n * Specifies the {@link ErrorPolicy} to be used for this operation\n */\n errorPolicy?: ErrorPolicy;\n\n /**\n * An object that maps from the name of a variable as used in the mutation\n * GraphQL document to that variable's value.\n */\n variables?: TVariables;\n\n /**\n * The context to be passed to the link execution chain. This context will\n * only be used with this mutation. It will not be used with\n * `refetchQueries`. Refetched queries use the context they were\n * initialized with (since the initial context is stored as part of the\n * `ObservableQuery` instance). If a specific context is needed when\n * refetching queries, make sure it is configured (via the\n * [query `context` option](https://www.apollographql.com/docs/react/api/apollo-client#ApolloClient.query))\n * when the query is first initialized/run.\n */\n context?: TContext;\n}\n\nexport interface MutationOptions<\n TData = any,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n> extends MutationBaseOptions<TData, TVariables, TContext, TCache> {\n /**\n * A GraphQL document, often created with `gql` from the `graphql-tag`\n * package, that contains a single mutation inside of it.\n */\n mutation: DocumentNode | TypedDocumentNode<TData, TVariables>;\n\n /**\n * Specifies the {@link MutationFetchPolicy} to be used for this query.\n * Mutations support only 'network-only' and 'no-cache' fetchPolicy strings.\n * If fetchPolicy is not provided, it defaults to 'network-only'.\n */\n fetchPolicy?: MutationFetchPolicy;\n\n /**\n * To avoid retaining sensitive information from mutation root field\n * arguments, Apollo Client v3.4+ automatically clears any `ROOT_MUTATION`\n * fields from the cache after each mutation finishes. If you need this\n * information to remain in the cache, you can prevent the removal by passing\n * `keepRootFields: true` to the mutation. `ROOT_MUTATION` result data are\n * also passed to the mutation `update` function, so we recommend obtaining\n * the results that way, rather than using this option, if possible.\n */\n keepRootFields?: boolean;\n}\n"]}
|
package/invariantErrorCodes.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// consult the @apollo/client/invariantErrorCodes.js file specific to
|
|
6
6
|
// your @apollo/client version. This file is not meant to be imported.
|
|
7
7
|
{
|
|
8
|
-
"@apollo/client version": "3.7.
|
|
8
|
+
"@apollo/client version": "3.7.5",
|
|
9
9
|
|
|
10
10
|
1: {
|
|
11
11
|
file: "@apollo/client/cache/inmemory/entityStore.js",
|
package/link/context/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ApolloLink, GraphQLRequest } from '../core';
|
|
2
|
-
|
|
2
|
+
import { DefaultContext } from '../../core';
|
|
3
|
+
export declare type ContextSetter = (operation: GraphQLRequest, prevContext: DefaultContext) => Promise<DefaultContext> | DefaultContext;
|
|
3
4
|
export declare function setContext(setter: ContextSetter): ApolloLink;
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/link/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,cAAc,EAAY,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/link/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,cAAc,EAAY,MAAM,SAAS,CAAC;AAE1E,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,oBAAY,aAAa,GAAG,CAC1B,SAAS,EAAE,cAAc,EACzB,WAAW,EAAE,cAAc,KACxB,OAAO,CAAC,cAAc,CAAC,GAAG,cAAc,CAAC;AAE9C,wBAAgB,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,UAAU,CA2B5D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/link/context/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAuC,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,UAAU,EAA0B,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src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operation, GraphQLRequest, NextLink } from '../core';\nimport { Observable, ObservableSubscription } from '../../utilities';\nimport { DefaultContext } from '../../core';\n\nexport type ContextSetter = (\n operation: GraphQLRequest,\n prevContext: DefaultContext,\n) => Promise<DefaultContext> | DefaultContext;\n\nexport function setContext(setter: ContextSetter): ApolloLink {\n return new ApolloLink((operation: Operation, forward: NextLink) => {\n const { ...request } = operation;\n\n return new Observable(observer => {\n let handle: ObservableSubscription;\n let closed = false;\n Promise.resolve(request)\n .then(req => setter(req, operation.getContext()))\n .then(operation.setContext)\n .then(() => {\n // if the observer is already closed, no need to subscribe.\n if (closed) return;\n handle = forward(operation).subscribe({\n next: observer.next.bind(observer),\n error: observer.error.bind(observer),\n complete: observer.complete.bind(observer),\n });\n })\n .catch(observer.error.bind(observer));\n\n return () => {\n closed = true;\n if (handle) handle.unsubscribe();\n };\n });\n });\n}\n"]}
|
package/link/core/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DocumentNode, ExecutionResult, GraphQLError } from "graphql";
|
|
2
|
+
import { DefaultContext } from "../../core";
|
|
2
3
|
export { DocumentNode };
|
|
3
4
|
import { Observable } from "../../utilities";
|
|
4
5
|
export declare type Path = ReadonlyArray<string | number>;
|
|
@@ -30,7 +31,7 @@ export interface GraphQLRequest {
|
|
|
30
31
|
query: DocumentNode;
|
|
31
32
|
variables?: Record<string, any>;
|
|
32
33
|
operationName?: string;
|
|
33
|
-
context?:
|
|
34
|
+
context?: DefaultContext;
|
|
34
35
|
extensions?: Record<string, any>;
|
|
35
36
|
}
|
|
36
37
|
export interface Operation {
|
|
@@ -38,10 +39,10 @@ export interface Operation {
|
|
|
38
39
|
variables: Record<string, any>;
|
|
39
40
|
operationName: string;
|
|
40
41
|
extensions: Record<string, any>;
|
|
41
|
-
setContext: (context:
|
|
42
|
-
getContext: () =>
|
|
42
|
+
setContext: (context: DefaultContext) => DefaultContext;
|
|
43
|
+
getContext: () => DefaultContext;
|
|
43
44
|
}
|
|
44
|
-
export interface SingleExecutionResult<TData = Record<string, any>, TContext =
|
|
45
|
+
export interface SingleExecutionResult<TData = Record<string, any>, TContext = DefaultContext, TExtensions = Record<string, any>> extends ExecutionResult<TData, TExtensions> {
|
|
45
46
|
data?: Data<TData>;
|
|
46
47
|
context?: TContext;
|
|
47
48
|
}
|
package/link/core/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/link/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,oBAAY,IAAI,GAAG,aAAa,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;AAClD,aAAK,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;AAGpC,UAAU,wBAAwB;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,2BAA2B,CAC1C,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CACjC,SAAQ,wBAAwB;IAEhC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAClB,WAAW,CAAC,EAAE,KAAK,CAAC;IACpB,MAAM,CAAC,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;IACrC,UAAU,CAAC,EAAE,WAAW,CAAC;CAC1B;AAED,MAAM,WAAW,kBAAkB,CACjC,KAAK,EACL,WAAW;IAIX,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,CAAC,EAAE,aAAa,CAAC,YAAY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AE,SAAS,KAAK,UAAU,CAAC,WAAW,CAAC,CAAC;AAEzE,oBAAY,cAAc,GAAG,CAC3B,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,QAAQ,KACd,UAAU,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC"}
|
package/link/core/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/link/core/types.ts"],"names":[],"mappings":"","sourcesContent":["import { DocumentNode, ExecutionResult, GraphQLError } from \"graphql\";\nexport { DocumentNode };\n\nimport { Observable } from \"../../utilities\";\n\nexport type Path = ReadonlyArray<string | number>;\ntype Data<T> = T | null | undefined;\n\n\ninterface ExecutionPatchResultBase {\n hasNext?: boolean;\n}\n\nexport interface ExecutionPatchInitialResult<\n TData = Record<string, any>,\n TExtensions = Record<string, any>\n> extends ExecutionPatchResultBase {\n // if data is present, incremental is not\n data: Data<TData>;\n incremental?: never;\n errors?: ReadonlyArray<GraphQLError>;\n extensions?: TExtensions;\n}\n\nexport interface IncrementalPayload<\n TData,\n TExtensions,\n> {\n // data and path must both be present\n // https://github.com/graphql/graphql-spec/pull/742/files#diff-98d0cd153b72b63c417ad4238e8cc0d3385691ccbde7f7674bc0d2a718b896ecR288-R293\n data: Data<TData>;\n label?: string;\n path: Path;\n errors?: ReadonlyArray<GraphQLError>;\n extensions?: TExtensions;\n}\n\nexport interface ExecutionPatchIncrementalResult<\n TData = Record<string, any>,\n TExtensions = Record<string, any>\n> extends ExecutionPatchResultBase {\n // the reverse is also true: if incremental is present,\n // data (and errors and extensions) are not\n incremental?: IncrementalPayload<TData, TExtensions>[];\n data?: never;\n // Errors only exist for chunks, not at the top level\n // https://github.com/robrichard/defer-stream-wg/discussions/50#discussioncomment-3466739\n errors?: never;\n extensions?: never;\n}\n\nexport type ExecutionPatchResult<\n TData = Record<string, any>,\n TExtensions = Record<string, any>\n> =\n | ExecutionPatchInitialResult<TData, TExtensions>\n | ExecutionPatchIncrementalResult<TData, TExtensions>;\n\nexport interface GraphQLRequest {\n query: DocumentNode;\n variables?: Record<string, any>;\n operationName?: string;\n context?:
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/link/core/types.ts"],"names":[],"mappings":"","sourcesContent":["import { DocumentNode, ExecutionResult, GraphQLError } from \"graphql\";\nimport { DefaultContext } from \"../../core\";\nexport { DocumentNode };\n\nimport { Observable } from \"../../utilities\";\n\nexport type Path = ReadonlyArray<string | number>;\ntype Data<T> = T | null | undefined;\n\n\ninterface ExecutionPatchResultBase {\n hasNext?: boolean;\n}\n\nexport interface ExecutionPatchInitialResult<\n TData = Record<string, any>,\n TExtensions = Record<string, any>\n> extends ExecutionPatchResultBase {\n // if data is present, incremental is not\n data: Data<TData>;\n incremental?: never;\n errors?: ReadonlyArray<GraphQLError>;\n extensions?: TExtensions;\n}\n\nexport interface IncrementalPayload<\n TData,\n TExtensions,\n> {\n // data and path must both be present\n // https://github.com/graphql/graphql-spec/pull/742/files#diff-98d0cd153b72b63c417ad4238e8cc0d3385691ccbde7f7674bc0d2a718b896ecR288-R293\n data: Data<TData>;\n label?: string;\n path: Path;\n errors?: ReadonlyArray<GraphQLError>;\n extensions?: TExtensions;\n}\n\nexport interface ExecutionPatchIncrementalResult<\n TData = Record<string, any>,\n TExtensions = Record<string, any>\n> extends ExecutionPatchResultBase {\n // the reverse is also true: if incremental is present,\n // data (and errors and extensions) are not\n incremental?: IncrementalPayload<TData, TExtensions>[];\n data?: never;\n // Errors only exist for chunks, not at the top level\n // https://github.com/robrichard/defer-stream-wg/discussions/50#discussioncomment-3466739\n errors?: never;\n extensions?: never;\n}\n\nexport type ExecutionPatchResult<\n TData = Record<string, any>,\n TExtensions = Record<string, any>\n> =\n | ExecutionPatchInitialResult<TData, TExtensions>\n | ExecutionPatchIncrementalResult<TData, TExtensions>;\n\nexport interface GraphQLRequest {\n query: DocumentNode;\n variables?: Record<string, any>;\n operationName?: string;\n context?: DefaultContext;\n extensions?: Record<string, any>;\n}\n\nexport interface Operation {\n query: DocumentNode;\n variables: Record<string, any>;\n operationName: string;\n extensions: Record<string, any>;\n setContext: (context: DefaultContext) => DefaultContext;\n getContext: () => DefaultContext;\n}\n\nexport interface SingleExecutionResult<\n TData = Record<string, any>,\n TContext = DefaultContext,\n TExtensions = Record<string, any>\n> extends ExecutionResult<TData, TExtensions> {\n data?: Data<TData>;\n context?: TContext;\n}\n\nexport type FetchResult<\n TData = Record<string, any>,\n TContext = Record<string, any>,\n TExtensions = Record<string, any>\n> =\n | SingleExecutionResult<TData, TContext, TExtensions>\n | ExecutionPatchResult<TData, TExtensions>;\n\nexport type NextLink = (operation: Operation) => Observable<FetchResult>;\n\nexport type RequestHandler = (\n operation: Operation,\n forward: NextLink\n) => Observable<FetchResult> | null;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createHttpLink.d.ts","sourceRoot":"","sources":["../../../src/link/http/createHttpLink.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AAIjC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAUrC,OAAO,EAIL,WAAW,EACZ,MAAM,4BAA4B,CAAC;AAQpC,eAAO,MAAM,cAAc,iBAAiB,WAAW,
|
|
1
|
+
{"version":3,"file":"createHttpLink.d.ts","sourceRoot":"","sources":["../../../src/link/http/createHttpLink.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AAIjC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAUrC,OAAO,EAIL,WAAW,EACZ,MAAM,4BAA4B,CAAC;AAQpC,eAAO,MAAM,cAAc,iBAAiB,WAAW,eA+JtD,CAAC"}
|
|
@@ -77,6 +77,7 @@ export var createHttpLink = function (linkOptions) {
|
|
|
77
77
|
options.method = 'GET';
|
|
78
78
|
}
|
|
79
79
|
if (hasDirectives(['defer'], operation.query)) {
|
|
80
|
+
options.headers = options.headers || {};
|
|
80
81
|
options.headers.accept = "multipart/mixed; deferSpec=20220824, application/json";
|
|
81
82
|
}
|
|
82
83
|
if (options.method === 'GET') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createHttpLink.js","sourceRoot":"","sources":["../../../src/link/http/createHttpLink.ts"],"names":[],"mappings":";AAAA,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EAAE,KAAK,EAA0C,MAAM,SAAS,CAAC;AAExE,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,YAAY,EACb,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EACL,gCAAgC,EAChC,cAAc,EACd,kBAAkB,EAEnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAExC,IAAM,WAAW,GAAG,KAAK,CAAC,cAAM,OAAA,KAAK,EAAL,CAAK,CAAC,CAAC;AAEvC,MAAM,CAAC,IAAM,cAAc,GAAG,UAAC,WAA6B;IAA7B,4BAAA,EAAA,gBAA6B;IAExD,IAAA,KASE,WAAW,IATG,EAAhB,GAAG,mBAAG,UAAU,KAAA,EAET,cAAc,GAOnB,WAAW,MAPQ,EACrB,KAME,WAAW,MANS,EAAtB,KAAK,mBAAG,cAAc,KAAA,EACtB,iBAAiB,GAKf,WAAW,kBALI,EACjB,kBAAkB,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AAQ,CAAC,CAAC;iBACpD;YACH,CAAC,CAAC;iBACD,KAAK,CAAC,UAAA,GAAG,IAAI,OAAA,WAAW,CAAC,GAAG,EAAE,QAAQ,CAAC,EAA1B,CAA0B,CAAC,CAAC;YAE5C,OAAO;gBAGL,IAAI,UAAU;oBAAE,UAAU,CAAC,KAAK,EAAE,CAAC;YACrC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import '../../utilities/globals';\n\nimport { visit, DefinitionNode, VariableDefinitionNode } from 'graphql';\n\nimport { ApolloLink } from '../core';\nimport { Observable, hasDirectives } from '../../utilities';\nimport { serializeFetchParameter } from './serializeFetchParameter';\nimport { selectURI } from './selectURI';\nimport {\n handleError,\n readMultipartBody,\n readJsonBody\n} from './parseAndCheckHttpResponse';\nimport { checkFetcher } from './checkFetcher';\nimport {\n selectHttpOptionsAndBodyInternal,\n defaultPrinter,\n fallbackHttpConfig,\n HttpOptions\n} from './selectHttpOptionsAndBody';\nimport { createSignalIfSupported } from './createSignalIfSupported';\nimport { rewriteURIForGET } from './rewriteURIForGET';\nimport { fromError } from '../utils';\nimport { maybe } from '../../utilities';\n\nconst backupFetch = maybe(() => fetch);\n\nexport const createHttpLink = (linkOptions: HttpOptions = {}) => {\n let {\n uri = '/graphql',\n // use default global fetch if nothing passed in\n fetch: preferredFetch,\n print = defaultPrinter,\n includeExtensions,\n preserveHeaderCase,\n useGETForQueries,\n includeUnusedVariables = false,\n ...requestOptions\n } = linkOptions;\n\n if (__DEV__) {\n // Make sure at least one of preferredFetch, window.fetch, or backupFetch is\n // defined, so requests won't fail at runtime.\n checkFetcher(preferredFetch || backupFetch);\n }\n\n const linkConfig = {\n http: { includeExtensions, preserveHeaderCase },\n options: requestOptions.fetchOptions,\n credentials: requestOptions.credentials,\n headers: requestOptions.headers,\n };\n\n return new ApolloLink(operation => {\n let chosenURI = selectURI(operation, uri);\n\n const context = operation.getContext();\n\n // `apollographql-client-*` headers are automatically set if a\n // `clientAwareness` object is found in the context. These headers are\n // set first, followed by the rest of the headers pulled from\n // `context.headers`. If desired, `apollographql-client-*` headers set by\n // the `clientAwareness` object can be overridden by\n // `apollographql-client-*` headers set in `context.headers`.\n const clientAwarenessHeaders: {\n 'apollographql-client-name'?: string;\n 'apollographql-client-version'?: string;\n } = {};\n\n if (context.clientAwareness) {\n const { name, version } = context.clientAwareness;\n if (name) {\n clientAwarenessHeaders['apollographql-client-name'] = name;\n }\n if (version) {\n clientAwarenessHeaders['apollographql-client-version'] = version;\n }\n }\n\n const contextHeaders = { ...clientAwarenessHeaders, ...context.headers };\n\n const contextConfig = {\n http: context.http,\n options: context.fetchOptions,\n credentials: context.credentials,\n headers: contextHeaders,\n };\n\n //uses fallback, link, and then context to build options\n const { options, body } = selectHttpOptionsAndBodyInternal(\n operation,\n print,\n fallbackHttpConfig,\n linkConfig,\n contextConfig,\n );\n\n if (body.variables && !includeUnusedVariables) {\n const unusedNames = new Set(Object.keys(body.variables));\n visit(operation.query, {\n Variable(node, _key, parent) {\n // A variable type definition at the top level of a query is not\n // enough to silence server-side errors about the variable being\n // unused, so variable definitions do not count as usage.\n // https://spec.graphql.org/draft/#sec-All-Variables-Used\n if (parent && (parent as VariableDefinitionNode).kind !== 'VariableDefinition') {\n unusedNames.delete(node.name.value);\n }\n },\n });\n if (unusedNames.size) {\n // Make a shallow copy of body.variables (with keys in the same\n // order) and then delete unused variables from the copy.\n body.variables = { ...body.variables };\n unusedNames.forEach(name => {\n delete body.variables![name];\n });\n }\n }\n\n let controller: any;\n if (!(options as any).signal) {\n const { controller: _controller, signal } = createSignalIfSupported();\n controller = _controller;\n if (controller) (options as any).signal = signal;\n }\n\n // If requested, set method to GET if there are no mutations.\n const definitionIsMutation = (d: DefinitionNode) => {\n return d.kind === 'OperationDefinition' && d.operation === 'mutation';\n };\n if (\n useGETForQueries &&\n !operation.query.definitions.some(definitionIsMutation)\n ) {\n options.method = 'GET';\n }\n\n // does not match custom directives beginning with @defer\n if (hasDirectives(['defer'], operation.query)) {\n options.headers.accept = \"multipart/mixed; deferSpec=20220824, application/json\";\n }\n\n if (options.method === 'GET') {\n const { newURI, parseError } = rewriteURIForGET(chosenURI, body);\n if (parseError) {\n return fromError(parseError);\n }\n chosenURI = newURI;\n } else {\n try {\n (options as any).body = serializeFetchParameter(body, 'Payload');\n } catch (parseError) {\n return fromError(parseError);\n }\n }\n\n return new Observable(observer => {\n // Prefer linkOptions.fetch (preferredFetch) if provided, and otherwise\n // fall back to the *current* global window.fetch function (see issue\n // #7832), or (if all else fails) the backupFetch function we saved when\n // this module was first evaluated. This last option protects against the\n // removal of window.fetch, which is unlikely but not impossible.\n const currentFetch = preferredFetch || maybe(() => fetch) || backupFetch;\n\n currentFetch!(chosenURI, options)\n .then(response => {\n operation.setContext({ response });\n const ctype = response.headers?.get('content-type');\n\n if (ctype !== null && /^multipart\\/mixed/i.test(ctype)) {\n return readMultipartBody(response, observer);\n } else {\n return readJsonBody(response, operation, observer);\n }\n })\n .catch(err => handleError(err, observer));\n\n return () => {\n // XXX support canceling this request\n // https://developers.google.com/web/updates/2017/09/abortable-fetch\n if (controller) controller.abort();\n };\n });\n });\n};\n"]}
|
|
1
|
+
{"version":3,"file":"createHttpLink.js","sourceRoot":"","sources":["../../../src/link/http/createHttpLink.ts"],"names":[],"mappings":";AAAA,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EAAE,KAAK,EAA0C,MAAM,SAAS,CAAC;AAExE,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,YAAY,EACb,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,YAAY,EA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AAG,uBAAuB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;aAClE;YAAC,OAAO,UAAU,EAAE;gBACnB,OAAO,SAAS,CAAC,UAAU,CAAC,CAAC;aAC9B;SACF;QAED,OAAO,IAAI,UAAU,CAAC,UAAA,QAAQ;YAM5B,IAAM,YAAY,GAAG,cAAc,IAAI,KAAK,CAAC,cAAM,OAAA,KAAK,EAAL,CAAK,CAAC,IAAI,WAAW,CAAC;YAEzE,YAAa,CAAC,SAAS,EAAE,OAAO,CAAC;iBAC9B,IAAI,CAAC,UAAA,QAAQ;;gBACZ,SAAS,CAAC,UAAU,CAAC,EAAE,QAAQ,UAAA,EAAE,CAAC,CAAC;gBACnC,IAAM,KAAK,GAAG,MAAA,QAAQ,CAAC,OAAO,0CAAE,GAAG,CAAC,cAAc,CAAC,CAAC;gBAEpD,IAAI,KAAK,KAAK,IAAI,IAAI,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;oBACtD,OAAO,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;iBAC9C;qBAAM;oBACL,OAAO,YAAY,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;iBACpD;YACH,CAAC,CAAC;iBACD,KAAK,CAAC,UAAA,GAAG,IAAI,OAAA,WAAW,CAAC,GAAG,EAAE,QAAQ,CAAC,EAA1B,CAA0B,CAAC,CAAC;YAE5C,OAAO;gBAGL,IAAI,UAAU;oBAAE,UAAU,CAAC,KAAK,EAAE,CAAC;YACrC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import '../../utilities/globals';\n\nimport { visit, DefinitionNode, VariableDefinitionNode } from 'graphql';\n\nimport { ApolloLink } from '../core';\nimport { Observable, hasDirectives } from '../../utilities';\nimport { serializeFetchParameter } from './serializeFetchParameter';\nimport { selectURI } from './selectURI';\nimport {\n handleError,\n readMultipartBody,\n readJsonBody\n} from './parseAndCheckHttpResponse';\nimport { checkFetcher } from './checkFetcher';\nimport {\n selectHttpOptionsAndBodyInternal,\n defaultPrinter,\n fallbackHttpConfig,\n HttpOptions\n} from './selectHttpOptionsAndBody';\nimport { createSignalIfSupported } from './createSignalIfSupported';\nimport { rewriteURIForGET } from './rewriteURIForGET';\nimport { fromError } from '../utils';\nimport { maybe } from '../../utilities';\n\nconst backupFetch = maybe(() => fetch);\n\nexport const createHttpLink = (linkOptions: HttpOptions = {}) => {\n let {\n uri = '/graphql',\n // use default global fetch if nothing passed in\n fetch: preferredFetch,\n print = defaultPrinter,\n includeExtensions,\n preserveHeaderCase,\n useGETForQueries,\n includeUnusedVariables = false,\n ...requestOptions\n } = linkOptions;\n\n if (__DEV__) {\n // Make sure at least one of preferredFetch, window.fetch, or backupFetch is\n // defined, so requests won't fail at runtime.\n checkFetcher(preferredFetch || backupFetch);\n }\n\n const linkConfig = {\n http: { includeExtensions, preserveHeaderCase },\n options: requestOptions.fetchOptions,\n credentials: requestOptions.credentials,\n headers: requestOptions.headers,\n };\n\n return new ApolloLink(operation => {\n let chosenURI = selectURI(operation, uri);\n\n const context = operation.getContext();\n\n // `apollographql-client-*` headers are automatically set if a\n // `clientAwareness` object is found in the context. These headers are\n // set first, followed by the rest of the headers pulled from\n // `context.headers`. If desired, `apollographql-client-*` headers set by\n // the `clientAwareness` object can be overridden by\n // `apollographql-client-*` headers set in `context.headers`.\n const clientAwarenessHeaders: {\n 'apollographql-client-name'?: string;\n 'apollographql-client-version'?: string;\n } = {};\n\n if (context.clientAwareness) {\n const { name, version } = context.clientAwareness;\n if (name) {\n clientAwarenessHeaders['apollographql-client-name'] = name;\n }\n if (version) {\n clientAwarenessHeaders['apollographql-client-version'] = version;\n }\n }\n\n const contextHeaders = { ...clientAwarenessHeaders, ...context.headers };\n\n const contextConfig = {\n http: context.http,\n options: context.fetchOptions,\n credentials: context.credentials,\n headers: contextHeaders,\n };\n\n //uses fallback, link, and then context to build options\n const { options, body } = selectHttpOptionsAndBodyInternal(\n operation,\n print,\n fallbackHttpConfig,\n linkConfig,\n contextConfig,\n );\n\n if (body.variables && !includeUnusedVariables) {\n const unusedNames = new Set(Object.keys(body.variables));\n visit(operation.query, {\n Variable(node, _key, parent) {\n // A variable type definition at the top level of a query is not\n // enough to silence server-side errors about the variable being\n // unused, so variable definitions do not count as usage.\n // https://spec.graphql.org/draft/#sec-All-Variables-Used\n if (parent && (parent as VariableDefinitionNode).kind !== 'VariableDefinition') {\n unusedNames.delete(node.name.value);\n }\n },\n });\n if (unusedNames.size) {\n // Make a shallow copy of body.variables (with keys in the same\n // order) and then delete unused variables from the copy.\n body.variables = { ...body.variables };\n unusedNames.forEach(name => {\n delete body.variables![name];\n });\n }\n }\n\n let controller: any;\n if (!(options as any).signal) {\n const { controller: _controller, signal } = createSignalIfSupported();\n controller = _controller;\n if (controller) (options as any).signal = signal;\n }\n\n // If requested, set method to GET if there are no mutations.\n const definitionIsMutation = (d: DefinitionNode) => {\n return d.kind === 'OperationDefinition' && d.operation === 'mutation';\n };\n if (\n useGETForQueries &&\n !operation.query.definitions.some(definitionIsMutation)\n ) {\n options.method = 'GET';\n }\n\n // does not match custom directives beginning with @defer\n if (hasDirectives(['defer'], operation.query)) {\n options.headers = options.headers || {};\n options.headers.accept = \"multipart/mixed; deferSpec=20220824, application/json\";\n }\n\n if (options.method === 'GET') {\n const { newURI, parseError } = rewriteURIForGET(chosenURI, body);\n if (parseError) {\n return fromError(parseError);\n }\n chosenURI = newURI;\n } else {\n try {\n (options as any).body = serializeFetchParameter(body, 'Payload');\n } catch (parseError) {\n return fromError(parseError);\n }\n }\n\n return new Observable(observer => {\n // Prefer linkOptions.fetch (preferredFetch) if provided, and otherwise\n // fall back to the *current* global window.fetch function (see issue\n // #7832), or (if all else fails) the backupFetch function we saved when\n // this module was first evaluated. This last option protects against the\n // removal of window.fetch, which is unlikely but not impossible.\n const currentFetch = preferredFetch || maybe(() => fetch) || backupFetch;\n\n currentFetch!(chosenURI, options)\n .then(response => {\n operation.setContext({ response });\n const ctype = response.headers?.get('content-type');\n\n if (ctype !== null && /^multipart\\/mixed/i.test(ctype)) {\n return readMultipartBody(response, observer);\n } else {\n return readJsonBody(response, operation, observer);\n }\n })\n .catch(err => handleError(err, observer));\n\n return () => {\n // XXX support canceling this request\n // https://developers.google.com/web/updates/2017/09/abortable-fetch\n if (controller) controller.abort();\n };\n });\n });\n};\n"]}
|
package/link/http/http.cjs
CHANGED
|
@@ -379,7 +379,9 @@ function selectHttpOptionsAndBodyInternal(operation, printer) {
|
|
|
379
379
|
}
|
|
380
380
|
http = tslib.__assign(tslib.__assign({}, http), config.http);
|
|
381
381
|
});
|
|
382
|
-
|
|
382
|
+
if (options.headers) {
|
|
383
|
+
options.headers = removeDuplicateHeaders(options.headers, http.preserveHeaderCase);
|
|
384
|
+
}
|
|
383
385
|
var operationName = operation.operationName, extensions = operation.extensions, variables = operation.variables, query = operation.query;
|
|
384
386
|
var body = { operationName: operationName, variables: variables };
|
|
385
387
|
if (http.includeExtensions)
|
|
@@ -545,6 +547,7 @@ var createHttpLink = function (linkOptions) {
|
|
|
545
547
|
options.method = 'GET';
|
|
546
548
|
}
|
|
547
549
|
if (utilities.hasDirectives(['defer'], operation.query)) {
|
|
550
|
+
options.headers = options.headers || {};
|
|
548
551
|
options.headers.accept = "multipart/mixed; deferSpec=20220824, application/json";
|
|
549
552
|
}
|
|
550
553
|
if (options.method === 'GET') {
|