Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 3.11 #11922

Merged
merged 69 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
8df6013
MockLink: add query default variables if not specified in mock request
phryneas Apr 24, 2024
bcd51e0
move logic
phryneas Apr 24, 2024
7249ff6
Update src/testing/core/mocking/__tests__/mockLink.ts
phryneas May 2, 2024
ffb21ce
Enter prerelease mode
github-actions[bot] Jul 2, 2024
c2bd48b
extract hooks from InternalState
phryneas May 27, 2024
dc58beb
inline hooks and functions into each other, move `createWatchQueryOpt…
phryneas May 27, 2024
10466e5
move `executeQuery` to `useLazyQuery`
phryneas May 27, 2024
ea77f60
move more functions out
phryneas May 27, 2024
fde4c4d
move `unsafeHandlePartialRefetch` into `setResult`
phryneas May 28, 2024
e1b7ed7
remove `toQueryResultCache`, save transformed result in `internalStat…
phryneas May 29, 2024
9c865ca
fixup test
phryneas May 29, 2024
b5e1643
move `getDefaultFetchPolicy` out
phryneas May 29, 2024
b4c8bf9
move more functions out
phryneas May 29, 2024
12e19f9
moved all class methods out
phryneas May 29, 2024
24e4491
replace class with single mutable object
phryneas May 29, 2024
e31d953
move callbacks into their own ref
phryneas May 29, 2024
891e211
move `obsQueryFields` out of `internalState`
phryneas Jun 3, 2024
ec1c7a9
inline `useInternalState`
phryneas Jun 4, 2024
79566a8
redactor away `internalState.queryHookOptions`
phryneas Jun 4, 2024
873f24d
make function arguments more explicit
phryneas Jun 4, 2024
8bb445c
replace `internalState.watchQueryOptions` with `observable[lastWatchO…
phryneas Jun 5, 2024
635a32b
move observable fully into a readonly prop on internalState
phryneas Jun 5, 2024
d6de17f
remove all direct access to `internalState` after initializing
phryneas Jun 5, 2024
06d98ac
extract new `useInternalState` hook
phryneas Jun 5, 2024
7717b4f
extract `useResubscribeIfNecessary` hook
phryneas Jun 5, 2024
3889fff
add comment
phryneas Jun 5, 2024
da4b840
extract `bindObservableMethods`
phryneas Jun 7, 2024
f18b753
extract `useHandleSkip` and `useRegisterSSRObservable` hooks
phryneas Jun 7, 2024
8480ce6
extract useObservableSubscriptionResult hook
phryneas Jun 7, 2024
30b1769
change some method arguments. remove obsolete comment
phryneas Jun 7, 2024
c896885
curry `createMakeWatchQueryOptions`
phryneas Jun 7, 2024
1485651
bring function and hook argyuments into a common order
phryneas Jun 7, 2024
70f5aaf
Move `onQueryExecuted` into `useInternalState`
phryneas Jun 7, 2024
fed117b
some style adjustments to be more compiler-friendly
phryneas Jun 7, 2024
a69327c
remove R19 exception from test, chores
phryneas Jul 3, 2024
98e44f7
useSubscription: fix rules of React violations (#11863)
phryneas Jul 3, 2024
987aaad
Apply suggestions from code review
phryneas Jul 4, 2024
33c0fef
Merge branch 'release-3.11' into pr/rewrite-useQuery
phryneas Jul 4, 2024
5ae4876
Merge pull request #11869 from apollographql/pr/rewrite-useQuery
phryneas Jul 4, 2024
d88c7f8
Add `subscribeToMore` function to `useBackgroundQuery`, `useQueryRefH…
jerelmiller Jul 5, 2024
e9d26e5
Merge remote-tracking branch 'origin/release-3.11' into pr/mockLink-d…
phryneas Jul 8, 2024
5ac68eb
Merge pull request #11806 from apollographql/pr/mockLink-defaults
phryneas Jul 8, 2024
96422ce
Add `cause` field to `ApolloError`. (#11902)
phryneas Jul 8, 2024
228429a
Call `nextFetchPolicy` with "variables-changed" even if there is a `f…
phryneas Jul 8, 2024
2941824
Add `restart` function to `useSubscription` (#11927)
phryneas Jul 8, 2024
70406bf
add `ignoreResults` option to `useSubscription` (#11921)
phryneas Jul 8, 2024
a0868da
Merge branch 'main' into release-3.11
jerelmiller Jul 8, 2024
09a6677
also wrap createQueryPreloader (#11719)
phryneas Jul 9, 2024
602a678
forward `errorPolicy` option from `useSubscription` (#11928)
phryneas Jul 9, 2024
1b23337
Add ability to configure a name for the client for use with devtools …
jerelmiller Jul 9, 2024
5793301
Change usages of the `GraphQLError` type to `GraphQLFormattedError`. …
phryneas Jul 9, 2024
3812800
Support extensions in useSubscription (#11854)
jcostello-atlassian Jul 9, 2024
a768575
Deprecate experimental testing utilities (#11930)
jerelmiller Jul 9, 2024
b937136
Prepare for rc release
github-actions[bot] Jul 9, 2024
5688afd
Merge branch 'main' into release-3.11
jerelmiller Jul 9, 2024
d9f9d15
Version Packages (rc) (#11940)
github-actions[bot] Jul 9, 2024
7d833b8
Fix issue accessing mutations from devtools (#11946)
jerelmiller Jul 10, 2024
3dd6432
`watchFragment`: forward additional options to `diffOptions` (#11926)
phryneas Jul 10, 2024
4528918
remove deprecated `watchFragment` option, `canonizeResults` (#11949)
alessbell Jul 10, 2024
a3bbabe
Version Packages (rc) (#11947)
github-actions[bot] Jul 10, 2024
78332be
correctly test for error equality on jest (#11937)
phryneas Jul 11, 2024
c4cf577
Merge branch 'main' into release-3.11
phryneas Jul 15, 2024
8f3d7eb
Fix `optimisticResponse` function return type (#11944)
sneyderdev Jul 15, 2024
0de03af
add React 19 RC to `peerDependencies` (#11951)
phryneas Jul 15, 2024
4a6e86a
optimize `useQuery` result handling (#11954)
phryneas Jul 15, 2024
5da4b21
QueryManager: require all options (#11920)
phryneas Jul 15, 2024
4e2a0bb
Version Packages (rc) (#11952)
github-actions[bot] Jul 15, 2024
56f1c93
patch React 19 for tests to make FALLBACK_THROTTLE_MS configurable (#…
phryneas Jul 19, 2024
f7aed4f
Exit prerelease mode
github-actions[bot] Jul 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .api-reports/api-report-cache.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -976,8 +976,6 @@ export type TypePolicy = {

// @public
export interface WatchFragmentOptions<TData, TVars> {
// @deprecated (undocumented)
canonizeResults?: boolean;
fragment: DocumentNode | TypedDocumentNode<TData, TVars>;
fragmentName?: string;
from: StoreObject | Reference | string;
Expand Down
104 changes: 67 additions & 37 deletions .api-reports/api-report-core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import { disableExperimentalFragmentVariables } from 'graphql-tag';
import { disableFragmentWarnings } from 'graphql-tag';
import type { DocumentNode } from 'graphql';
import { enableExperimentalFragmentVariables } from 'graphql-tag';
import type { ExecutionResult } from 'graphql';
import type { FieldNode } from 'graphql';
import type { FormattedExecutionResult } from 'graphql';
import type { FragmentDefinitionNode } from 'graphql';
import { gql } from 'graphql-tag';
import type { GraphQLError } from 'graphql';
import type { GraphQLErrorExtensions } from 'graphql';
import type { GraphQLFormattedError } from 'graphql';
import type { InlineFragmentNode } from 'graphql';
import { InvariantError } from 'ts-invariant';
import { Observable } from 'zen-observable-ts';
Expand Down Expand Up @@ -94,7 +94,7 @@ export class ApolloClient<TCacheShape> implements DataProxy {
__actionHookForDevTools(cb: () => any): void;
constructor(options: ApolloClientOptions<TCacheShape>);
// (undocumented)
__requestRaw(payload: GraphQLRequest): Observable<ExecutionResult>;
__requestRaw(payload: GraphQLRequest): Observable<FormattedExecutionResult>;
addResolvers(resolvers: Resolvers | Resolvers[]): void;
// (undocumented)
cache: ApolloCache<TCacheShape>;
Expand All @@ -103,6 +103,10 @@ export class ApolloClient<TCacheShape> implements DataProxy {
get defaultContext(): Partial<DefaultContext>;
// (undocumented)
defaultOptions: DefaultOptions;
// Warning: (ae-forgotten-export) The symbol "DevtoolsOptions" needs to be exported by the entry point index.d.ts
//
// (undocumented)
readonly devtoolsConfig: DevtoolsOptions;
// (undocumented)
disableNetworkFetches: boolean;
get documentTransform(): DocumentTransform;
Expand Down Expand Up @@ -144,12 +148,14 @@ export class ApolloClient<TCacheShape> implements DataProxy {
export interface ApolloClientOptions<TCacheShape> {
assumeImmutableResults?: boolean;
cache: ApolloCache<TCacheShape>;
// @deprecated
connectToDevTools?: boolean;
// (undocumented)
credentials?: string;
// (undocumented)
defaultContext?: Partial<DefaultContext>;
defaultOptions?: DefaultOptions;
devtools?: DevtoolsOptions;
// (undocumented)
documentTransform?: DocumentTransform;
// (undocumented)
Expand All @@ -172,14 +178,16 @@ export interface ApolloClientOptions<TCacheShape> {
export class ApolloError extends Error {
// Warning: (ae-forgotten-export) The symbol "ApolloErrorOptions" needs to be exported by the entry point index.d.ts
constructor({ graphQLErrors, protocolErrors, clientErrors, networkError, errorMessage, extraInfo, }: ApolloErrorOptions);
cause: ({
readonly message: string;
extensions?: GraphQLErrorExtensions[] | GraphQLFormattedError["extensions"];
} & Omit<Partial<Error> & Partial<GraphQLFormattedError>, "extensions">) | null;
// (undocumented)
clientErrors: ReadonlyArray<Error>;
// (undocumented)
extraInfo: any;
// Warning: (ae-forgotten-export) The symbol "GraphQLErrors" needs to be exported by the entry point index.d.ts
//
// (undocumented)
graphQLErrors: GraphQLErrors;
graphQLErrors: ReadonlyArray<GraphQLFormattedError>;
// (undocumented)
message: string;
// (undocumented)
Expand All @@ -202,7 +210,7 @@ interface ApolloErrorOptions {
// (undocumented)
extraInfo?: any;
// (undocumented)
graphQLErrors?: ReadonlyArray<GraphQLError>;
graphQLErrors?: ReadonlyArray<GraphQLFormattedError>;
// (undocumented)
networkError?: Error | ServerParseError | ServerError | null;
// (undocumented)
Expand Down Expand Up @@ -256,7 +264,7 @@ export interface ApolloQueryResult<T> {
// (undocumented)
data: T;
error?: ApolloError;
errors?: ReadonlyArray<GraphQLError>;
errors?: ReadonlyArray<GraphQLFormattedError>;
// (undocumented)
loading: boolean;
// (undocumented)
Expand Down Expand Up @@ -589,6 +597,12 @@ interface DeleteModifier {
// @public (undocumented)
const _deleteModifier: unique symbol;

// @public (undocumented)
interface DevtoolsOptions {
enabled?: boolean;
name?: string;
}

// @public (undocumented)
export type DiffQueryAgainstStoreOptions = ReadQueryOptions & {
returnPartialData?: boolean;
Expand Down Expand Up @@ -760,7 +774,7 @@ export interface ExecutionPatchInitialResult<TData = Record<string, any>, TExten
// (undocumented)
data: TData | null | undefined;
// (undocumented)
errors?: ReadonlyArray<GraphQLError>;
errors?: ReadonlyArray<GraphQLFormattedError>;
// (undocumented)
extensions?: TExtensions;
// (undocumented)
Expand Down Expand Up @@ -977,9 +991,6 @@ const getInMemoryCacheMemoryInternals: (() => {

export { gql }

// @public (undocumented)
type GraphQLErrors = ReadonlyArray<GraphQLError>;

// @public (undocumented)
export interface GraphQLRequest<TVariables = Record<string, any>> {
// (undocumented)
Expand Down Expand Up @@ -1064,7 +1075,7 @@ export interface IncrementalPayload<TData, TExtensions> {
// (undocumented)
data: TData | null;
// (undocumented)
errors?: ReadonlyArray<GraphQLError>;
errors?: ReadonlyArray<GraphQLFormattedError>;
// (undocumented)
extensions?: TExtensions;
// (undocumented)
Expand Down Expand Up @@ -1380,9 +1391,10 @@ interface MutationBaseOptions<TData = any, TVariables = OperationVariables, TCon
context?: TContext;
errorPolicy?: ErrorPolicy;
onQueryUpdated?: OnQueryUpdated<any>;
// Warning: (ae-forgotten-export) The symbol "IgnoreModifier" needs to be exported by the entry point index.d.ts
optimisticResponse?: TData | ((vars: TVariables, { IGNORE }: {
IGNORE: IgnoreModifier;
}) => TData);
}) => TData | IgnoreModifier);
refetchQueries?: ((result: FetchResult<TData>) => InternalRefetchQueriesInclude) | InternalRefetchQueriesInclude;
update?: MutationUpdaterFunction<TData, TVariables, TContext, TCache>;
updateQueries?: MutationQueryReducersMap<TData>;
Expand Down Expand Up @@ -1696,7 +1708,7 @@ class QueryInfo {
// (undocumented)
getDiff(): Cache_2.DiffResult<any>;
// (undocumented)
graphQLErrors?: ReadonlyArray<GraphQLError>;
graphQLErrors?: ReadonlyArray<GraphQLFormattedError>;
// (undocumented)
init(query: {
document: DocumentNode;
Expand Down Expand Up @@ -1750,19 +1762,8 @@ export type QueryListener = (queryInfo: QueryInfo) => void;

// @public (undocumented)
class QueryManager<TStore> {
constructor({ cache, link, defaultOptions, documentTransform, queryDeduplication, onBroadcast, ssrMode, clientAwareness, localState, assumeImmutableResults, defaultContext, }: {
cache: ApolloCache<TStore>;
link: ApolloLink;
defaultOptions?: DefaultOptions;
documentTransform?: DocumentTransform;
queryDeduplication?: boolean;
onBroadcast?: () => void;
ssrMode?: boolean;
clientAwareness?: Record<string, string>;
localState?: LocalState<TStore>;
assumeImmutableResults?: boolean;
defaultContext?: Partial<DefaultContext>;
});
// Warning: (ae-forgotten-export) The symbol "QueryManagerOptions" needs to be exported by the entry point index.d.ts
constructor(options: QueryManagerOptions<TStore>);
// (undocumented)
readonly assumeImmutableResults: boolean;
// (undocumented)
Expand Down Expand Up @@ -1791,6 +1792,8 @@ class QueryManager<TStore> {
//
// (undocumented)
getDocumentInfo(document: DocumentNode): TransformCacheEntry;
// Warning: (ae-forgotten-export) The symbol "LocalState" needs to be exported by the entry point index.d.ts
//
// (undocumented)
getLocalState(): LocalState<TStore>;
// (undocumented)
Expand Down Expand Up @@ -1855,7 +1858,7 @@ class QueryManager<TStore> {
// (undocumented)
readonly ssrMode: boolean;
// (undocumented)
startGraphQLSubscription<T = any>({ query, fetchPolicy, errorPolicy, variables, context, }: SubscriptionOptions): Observable<FetchResult<T>>;
startGraphQLSubscription<T = any>({ query, fetchPolicy, errorPolicy, variables, context, extensions, }: SubscriptionOptions): Observable<FetchResult<T>>;
stop(): void;
// (undocumented)
stopQuery(queryId: string): void;
Expand All @@ -1867,6 +1870,32 @@ class QueryManager<TStore> {
watchQuery<T, TVariables extends OperationVariables = OperationVariables>(options: WatchQueryOptions<TVariables, T>): ObservableQuery<T, TVariables>;
}

// @public (undocumented)
interface QueryManagerOptions<TStore> {
// (undocumented)
assumeImmutableResults: boolean;
// (undocumented)
cache: ApolloCache<TStore>;
// (undocumented)
clientAwareness: Record<string, string>;
// (undocumented)
defaultContext: Partial<DefaultContext> | undefined;
// (undocumented)
defaultOptions: DefaultOptions;
// (undocumented)
documentTransform: DocumentTransform | null | undefined;
// (undocumented)
link: ApolloLink;
// (undocumented)
localState: LocalState<TStore>;
// (undocumented)
onBroadcast: undefined | (() => void);
// (undocumented)
queryDeduplication: boolean;
// (undocumented)
ssrMode: boolean;
}

// @public
interface QueryOptions<TVariables = OperationVariables, TData = any> {
// @deprecated
Expand Down Expand Up @@ -2073,11 +2102,15 @@ interface SharedWatchQueryOptions<TVariables extends OperationVariables, TData>
}

// @public (undocumented)
export interface SingleExecutionResult<TData = Record<string, any>, TContext = DefaultContext, TExtensions = Record<string, any>> extends ExecutionResult<TData, TExtensions> {
export interface SingleExecutionResult<TData = Record<string, any>, TContext = DefaultContext, TExtensions = Record<string, any>> {
// (undocumented)
context?: TContext;
// (undocumented)
data?: TData | null;
// (undocumented)
errors?: ReadonlyArray<GraphQLFormattedError>;
// (undocumented)
extensions?: TExtensions;
}

// @public (undocumented)
Expand Down Expand Up @@ -2127,6 +2160,7 @@ export type SubscribeToMoreOptions<TData = any, TSubscriptionVariables = Operati
export interface SubscriptionOptions<TVariables = OperationVariables, TData = any> {
context?: DefaultContext;
errorPolicy?: ErrorPolicy;
extensions?: Record<string, any>;
fetchPolicy?: FetchPolicy;
query: DocumentNode | TypedDocumentNode<TData, TVariables>;
variables?: TVariables;
Expand Down Expand Up @@ -2215,8 +2249,6 @@ export interface UriFunction {

// @public
export interface WatchFragmentOptions<TData, TVars> {
// @deprecated (undocumented)
canonizeResults?: boolean;
fragment: DocumentNode | TypedDocumentNode<TData, TVars>;
fragmentName?: string;
from: StoreObject | Reference | string;
Expand Down Expand Up @@ -2285,11 +2317,9 @@ interface WriteContext extends ReadMergeModifyContext {
// src/cache/inmemory/types.ts:139:3 - (ae-forgotten-export) The symbol "KeyFieldsFunction" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:116:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:117:5 - (ae-forgotten-export) The symbol "QueryInfo" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:124:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:158:5 - (ae-forgotten-export) The symbol "LocalState" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:390:7 - (ae-forgotten-export) The symbol "UpdateQueries" needs to be exported by the entry point index.d.ts
// src/core/watchQueryOptions.ts:269:2 - (ae-forgotten-export) The symbol "IgnoreModifier" needs to be exported by the entry point index.d.ts
// src/core/watchQueryOptions.ts:269:2 - (ae-forgotten-export) The symbol "UpdateQueryFn" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:138:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:382:7 - (ae-forgotten-export) The symbol "UpdateQueries" needs to be exported by the entry point index.d.ts
// src/core/watchQueryOptions.ts:275:2 - (ae-forgotten-export) The symbol "UpdateQueryFn" needs to be exported by the entry point index.d.ts
// src/link/http/selectHttpOptionsAndBody.ts:128:32 - (ae-forgotten-export) The symbol "HttpQueryOptions" needs to be exported by the entry point index.d.ts

// (No @packageDocumentation comment for this package)
Expand Down
22 changes: 15 additions & 7 deletions .api-reports/api-report-errors.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@

```ts

import type { ExecutionResult } from 'graphql';
import type { GraphQLError } from 'graphql';
import type { GraphQLErrorExtensions } from 'graphql';
import type { GraphQLFormattedError } from 'graphql';

// @public (undocumented)
export class ApolloError extends Error {
constructor({ graphQLErrors, protocolErrors, clientErrors, networkError, errorMessage, extraInfo, }: ApolloErrorOptions);
cause: ({
readonly message: string;
extensions?: GraphQLErrorExtensions[] | GraphQLFormattedError["extensions"];
} & Omit<Partial<Error> & Partial<GraphQLFormattedError>, "extensions">) | null;
// (undocumented)
clientErrors: ReadonlyArray<Error>;
// (undocumented)
extraInfo: any;
// (undocumented)
graphQLErrors: GraphQLErrors;
graphQLErrors: ReadonlyArray<GraphQLFormattedError>;
// (undocumented)
message: string;
// (undocumented)
Expand All @@ -42,7 +46,7 @@ export interface ApolloErrorOptions {
// (undocumented)
extraInfo?: any;
// (undocumented)
graphQLErrors?: ReadonlyArray<GraphQLError>;
graphQLErrors?: ReadonlyArray<GraphQLFormattedError>;
// (undocumented)
networkError?: Error | ServerParseError | ServerError | null;
// (undocumented)
Expand Down Expand Up @@ -77,7 +81,7 @@ interface ExecutionPatchInitialResult<TData = Record<string, any>, TExtensions =
// (undocumented)
data: TData | null | undefined;
// (undocumented)
errors?: ReadonlyArray<GraphQLError>;
errors?: ReadonlyArray<GraphQLFormattedError>;
// (undocumented)
extensions?: TExtensions;
// (undocumented)
Expand Down Expand Up @@ -109,7 +113,7 @@ type FetchResultWithSymbolExtensions<T> = FetchResult<T> & {
extensions: Record<string | symbol, any>;
};

// @public (undocumented)
// @public @deprecated (undocumented)
export type GraphQLErrors = ReadonlyArray<GraphQLError>;

// Warning: (ae-forgotten-export) The symbol "FetchResultWithSymbolExtensions" needs to be exported by the entry point index.d.ts
Expand All @@ -122,7 +126,7 @@ interface IncrementalPayload<TData, TExtensions> {
// (undocumented)
data: TData | null;
// (undocumented)
errors?: ReadonlyArray<GraphQLError>;
errors?: ReadonlyArray<GraphQLFormattedError>;
// (undocumented)
extensions?: TExtensions;
// (undocumented)
Expand Down Expand Up @@ -162,11 +166,15 @@ type ServerParseError = Error & {
// Warning: (ae-forgotten-export) The symbol "DefaultContext" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
interface SingleExecutionResult<TData = Record<string, any>, TContext = DefaultContext, TExtensions = Record<string, any>> extends ExecutionResult<TData, TExtensions> {
interface SingleExecutionResult<TData = Record<string, any>, TContext = DefaultContext, TExtensions = Record<string, any>> {
// (undocumented)
context?: TContext;
// (undocumented)
data?: TData | null;
// (undocumented)
errors?: ReadonlyArray<GraphQLFormattedError>;
// (undocumented)
extensions?: TExtensions;
}

// (No @packageDocumentation comment for this package)
Expand Down
Loading
Loading