Skip to content

Commit

Permalink
fix(ApolloClient): Pass TVariables to ObservableQuery in `watchQu…
Browse files Browse the repository at this point in the history
…ery`. (#4253)
  • Loading branch information
avocadowastaken authored and benjamn committed Dec 20, 2018
1 parent 4c78a05 commit a444e58
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/apollo-client/src/ApolloClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export default class ApolloClient<TCacheShape> implements DataProxy {
*/
public watchQuery<T, TVariables = OperationVariables>(
options: WatchQueryOptions<TVariables>,
): ObservableQuery<T> {
): ObservableQuery<T, TVariables> {
if (this.defaultOptions.watchQuery) {
options = {
...this.defaultOptions.watchQuery,
Expand All @@ -256,7 +256,7 @@ export default class ApolloClient<TCacheShape> implements DataProxy {
options = { ...options, fetchPolicy: 'cache-first' };
}

return this.initQueryManager().watchQuery<T>(options);
return this.initQueryManager().watchQuery<T, TVariables>(options);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions packages/apollo-client/src/core/QueryManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -640,10 +640,10 @@ export class QueryManager<TStore> {
// supposed to be refetched in the event of a store reset. Once we unify error handling for
// network errors and non-network errors, the shouldSubscribe option will go away.

public watchQuery<T>(
public watchQuery<T, TVariables = OperationVariables>(
options: WatchQueryOptions,
shouldSubscribe = true,
): ObservableQuery<T> {
): ObservableQuery<T, TVariables> {
if (options.fetchPolicy === 'standby') {
throw new Error(
'client.watchQuery cannot be called with fetchPolicy set to "standby"',
Expand All @@ -667,9 +667,9 @@ export class QueryManager<TStore> {
options.notifyOnNetworkStatusChange = false;
}

let transformedOptions = { ...options } as WatchQueryOptions;
let transformedOptions = { ...options } as WatchQueryOptions<TVariables>;

return new ObservableQuery<T>({
return new ObservableQuery<T, TVariables>({
scheduler: this.scheduler,
options: transformedOptions,
shouldSubscribe: shouldSubscribe,
Expand Down

0 comments on commit a444e58

Please sign in to comment.