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

Added graphql hoc missing data type generic #2525

Merged
merged 9 commits into from
Mar 10, 2019
15 changes: 10 additions & 5 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,33 @@ export interface QueryOpts<TGraphQLVariables = OperationVariables> {
partialRefetch?: boolean;
}

export interface GraphqlQueryControls<TGraphQLVariables = OperationVariables> {
export interface QueryControls<TData = any, TGraphQLVariables = OperationVariables> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change all usages of GraphqlQueryControls to QueryControls.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed all usages and added TData generic for better typing but I am not sure it will break something. I don't have good knowledge about all code base. Can you check and confirm changes?

error?: ApolloError;
networkStatus: number;
loading: boolean;
variables: TGraphQLVariables;
fetchMore: (
fetchMoreOptions: FetchMoreQueryOptions<any, any> & FetchMoreOptions,
) => Promise<ApolloQueryResult<any>>;
refetch: (variables?: TGraphQLVariables) => Promise<ApolloQueryResult<any>>;
fetchMoreOptions: FetchMoreQueryOptions<TGraphQLVariables, any> &
FetchMoreOptions<TData, TGraphQLVariables>,
) => Promise<ApolloQueryResult<TData>>;
refetch: (variables?: TGraphQLVariables) => Promise<ApolloQueryResult<TData>>;
startPolling: (pollInterval: number) => void;
stopPolling: () => void;
subscribeToMore: (options: SubscribeToMoreOptions) => () => void;
updateQuery: (mapFn: (previousQueryResult: any, options: UpdateQueryOptions<any>) => any) => void;
}

export interface GraphqlQueryControls<TGraphQLVariables = OperationVariables>
EricMcRay marked this conversation as resolved.
Show resolved Hide resolved
extends QueryControls<any, TGraphQLVariables> {}

// XXX remove in the next breaking semver change (3.0)
export type MutationFunc<TData = any, TVariables = OperationVariables> = MutationFn<
TData,
TVariables
>;

export type DataValue<TData, TGraphQLVariables = OperationVariables> = GraphqlQueryControls<
export type DataValue<TData, TGraphQLVariables = OperationVariables> = QueryControls<
TData,
TGraphQLVariables
> &
// data may not yet be loaded
Expand Down