Skip to content

Commit

Permalink
fix: check client type at runtime instead of in flow
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards1211 committed Aug 7, 2018
1 parent 9aa112a commit 0373c41
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
16 changes: 13 additions & 3 deletions flow-typed/npm/apollo-client_v2.x.x.js
Original file line number Diff line number Diff line change
@@ -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<T> = {
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;
Expand Down Expand Up @@ -62,7 +73,6 @@ declare module "apollo-client" {
mutationStore: MutationStore;
queryStore: QueryStore;
dataStore: DataStore<TStore>;
queries: Map<string, {document: DocumentNode, observableQuery: ObservableQuery<any>}>;

constructor({
link: ApolloLink,
Expand Down
8 changes: 6 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -21,11 +21,15 @@ function every<T>(array: $ReadOnlyArray<T>, predicate: (elem: T) => boolean): bo
}

export default async function refetch(
client: ApolloClient<any>,
client: mixed,
typenameOrTerms: string | $ReadOnlyArray<Term>,
ids?: ?any,
idField?: string
): Promise<any> {
if (!(client instanceof ApolloClient)) throw new Error(
`client must be an ApolloClient, instead got: ${String(client)}`
)

const types: Types = await getSchemaTypes(client)

let terms
Expand Down

0 comments on commit 0373c41

Please sign in to comment.