diff --git a/CHANGELOG.md b/CHANGELOG.md index e01756ceb5d..e87604f484f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,9 @@ - Unsubscribing the last observer from an `ObservableQuery` will once again unsubscribe from the underlying network `Observable` in all cases, as in Apollo Client 2.x, allowing network requests to be cancelled by unsubscribing.
[@javier-garcia-meteologica](https://github.com/javier-garcia-meteologica) in [#7165](https://github.com/apollographql/apollo-client/pull/7165) and [#7170](https://github.com/apollographql/apollo-client/pull/7170). +- The independent `QueryBaseOptions` and `ModifiableWatchQueryOptions` interface supertypes have been eliminated, and their fields are now defined by `QueryOptions`.
+ [@DCtheTall](https://github.com/DCtheTall) in [#7136](https://github.com/apollographql/apollo-client/pull/7136) + ## Improvements - Support inheritance of type and field policies, according to `possibleTypes`.
diff --git a/src/__tests__/ApolloClient.ts b/src/__tests__/ApolloClient.ts index 2f8a1870f18..323d6e3d435 100644 --- a/src/__tests__/ApolloClient.ts +++ b/src/__tests__/ApolloClient.ts @@ -2287,6 +2287,26 @@ describe('ApolloClient', () => { client.stop(); }); + + it('should be able to set all default query options', () => { + new ApolloClient({ + link: ApolloLink.empty(), + cache: new InMemoryCache(), + defaultOptions: { + query: { + query: {kind: 'Document', definitions: []}, + variables: {foo: 'bar'}, + errorPolicy: 'none', + context: null, + fetchPolicy: 'cache-first', + pollInterval: 100, + notifyOnNetworkStatusChange: true, + returnPartialData: true, + partialRefetch: true, + }, + }, + }); + }); }); describe('clearStore', () => { diff --git a/src/core/index.ts b/src/core/index.ts index 0ba2b5c8a22..52f6b125c09 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -12,7 +12,6 @@ export { UpdateQueryOptions, } from './ObservableQuery'; export { - QueryBaseOptions, QueryOptions, WatchQueryOptions, MutationOptions, diff --git a/src/core/watchQueryOptions.ts b/src/core/watchQueryOptions.ts index e3b2ebe6602..3cc707ad204 100644 --- a/src/core/watchQueryOptions.ts +++ b/src/core/watchQueryOptions.ts @@ -33,9 +33,9 @@ export type WatchQueryFetchPolicy = FetchPolicy | 'cache-and-network'; export type ErrorPolicy = 'none' | 'ignore' | 'all'; /** - * Common options shared across all query interfaces. + * Query options. */ -export interface QueryBaseOptions { +export interface QueryOptions { /** * A GraphQL document that consists of a single query to be sent down to the * server. @@ -59,24 +59,12 @@ export interface QueryBaseOptions * Context to be passed to link execution chain */ context?: any; -} -/** - * Query options. - */ -export interface QueryOptions - extends QueryBaseOptions { /** * Specifies the {@link FetchPolicy} to be used for this query */ fetchPolicy?: FetchPolicy; -} -/** - * We can change these options to an ObservableQuery - */ -export interface ModifiableWatchQueryOptions - extends QueryBaseOptions { /** * The time interval (in milliseconds) on which this query should be * refetched from the server. @@ -106,8 +94,7 @@ export interface ModifiableWatchQueryOptions - extends QueryBaseOptions, - ModifiableWatchQueryOptions { + extends Omit, 'fetchPolicy'> { /** * Specifies the {@link FetchPolicy} to be used for this query. */