diff --git a/flow-typed/npm/apollo-client_v2.x.x.js b/flow-typed/npm/apollo-client_v2.x.x.js index ee20819..0d2b4ce 100644 --- a/flow-typed/npm/apollo-client_v2.x.x.js +++ b/flow-typed/npm/apollo-client_v2.x.x.js @@ -1,9 +1,20 @@ // flow-typed signature: ae6dd2fff7718a6434052f6830bf129b // flow-typed version: 2cbae06e0e/apollo-client_v2.x.x/flow_>=v0.57.x -import type {DocumentNode, ExecutionResult, GraphQLError} from 'graphql'; - declare module "apollo-client" { + /** + * Types From graphql + * graphql types are maintained in the graphql-js repo + */ + declare type DocumentNode = any; + declare type ExecutionResult = { + data?: T, + extensions?: { [string]: any }, + errors?: any[] + }; + declare type GraphQLError = any; + /** End From graphql */ + declare type OperationVariables = { [key: string]: any }; declare export function print(ast: any): string; @@ -62,7 +73,6 @@ declare module "apollo-client" { mutationStore: MutationStore; queryStore: QueryStore; dataStore: DataStore; - queries: Map}>; constructor({ link: ApolloLink, diff --git a/src/index.js b/src/index.js index b27027b..82e26e1 100644 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,6 @@ // @flow -import type {ApolloClient} from 'apollo-client' +import {ApolloClient} from 'apollo-client' import getSchemaTypes from './getSchemaTypes' import type {Types} from './getSchemaTypes' import doesQueryContain from './doesQueryContain' @@ -21,11 +21,15 @@ function every(array: $ReadOnlyArray, predicate: (elem: T) => boolean): bo } export default async function refetch( - client: ApolloClient, + client: mixed, typenameOrTerms: string | $ReadOnlyArray, ids?: ?any, idField?: string ): Promise { + if (!(client instanceof ApolloClient)) throw new Error( + `client must be an ApolloClient, instead got: ${String(client)}` + ) + const types: Types = await getSchemaTypes(client) let terms