Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Replace duplicate ObservableQueryFields types defined in apollo-client #2281

Merged
merged 4 commits into from
Aug 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 5 additions & 2 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@
check for errors is to use the result `errors` property. <br/>
[@TLadd](https://github.com/TLadd) in [#1983](https://github.com/apollographql/react-apollo/pull/1983)
- Allow a custom `cache` object to be passed into the test-utils
`MockedProvider`. <br/>
`MockedProvider`. <br/>
[@palmfjord](https://github.com/palmfjord) in [#2254](https://github.com/apollographql/react-apollo/pull/2254)
- Make the `MockedProvider` `mocks` prop read only. <br/>
- Make the `MockedProvider` `mocks` prop read only. <br/>
[@amacleay](https://github.com/amacleay) in [#2284](https://github.com/apollographql/react-apollo/pull/2284)
- Remove duplicate `FetchMoreOptions` and `FetchMoreQueryOptions` types, and
instead import them from Apollo Client. <br/>
[@skovy](https://github.com/skovy) in [#2281](https://github.com/apollographql/react-apollo/pull/2281)

## 2.1.11 (August 9, 2018)

Expand Down
27 changes: 3 additions & 24 deletions src/Query.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import ApolloClient, {
ErrorPolicy,
ApolloQueryResult,
NetworkStatus,
FetchMoreOptions,
FetchMoreQueryOptions,
} from 'apollo-client';
import { DocumentNode } from 'graphql';
import { ZenObservable } from 'zen-observable-ts';
Expand All @@ -16,40 +18,17 @@ import { parser, DocumentType, IDocumentDefinition } from './parser';
const shallowEqual = require('fbjs/lib/shallowEqual');
const invariant = require('invariant');

// Improved FetchMoreOptions type, need to port them back to Apollo Client
export interface FetchMoreOptions<TData, TVariables> {
updateQuery: (
previousQueryResult: TData,
options: {
fetchMoreResult?: TData;
variables: TVariables;
},
) => TData;
}

// Improved FetchMoreQueryOptions type, need to port them back to Apollo Client
export interface FetchMoreQueryOptions<TVariables, K extends keyof TVariables> {
variables: Pick<TVariables, K>;
}

// XXX open types improvement PR to AC
// Improved ObservableQuery field types, need to port them back to Apollo Client
export type ObservableQueryFields<TData, TVariables> = Pick<
ObservableQuery<TData>,
'startPolling' | 'stopPolling' | 'subscribeToMore'
'startPolling' | 'stopPolling' | 'subscribeToMore' | 'updateQuery' | 'refetch' | 'variables'
> & {
variables: TVariables;
refetch: (variables?: TVariables) => Promise<ApolloQueryResult<TData>>;
fetchMore: (<K extends keyof TVariables>(
fetchMoreOptions: FetchMoreQueryOptions<TVariables, K> & FetchMoreOptions<TData, TVariables>,
) => Promise<ApolloQueryResult<TData>>) &
(<TData2, TVariables2, K extends keyof TVariables2>(
fetchMoreOptions: { query: DocumentNode } & FetchMoreQueryOptions<TVariables2, K> &
FetchMoreOptions<TData2, TVariables2>,
) => Promise<ApolloQueryResult<TData2>>);
updateQuery: (
mapFn: (previousQueryResult: TData, options: { variables?: TVariables }) => TData,
) => void;
};

function compact(obj: any) {
Expand Down