Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apollo Client 3: defaultOptions type does not contain partialRefetch #6177

Closed
kvnkusch opened this issue Apr 21, 2020 · 4 comments
Closed

Apollo Client 3: defaultOptions type does not contain partialRefetch #6177

kvnkusch opened this issue Apr 21, 2020 · 4 comments
Labels
📚 good-first-issue Issues that are suitable for first-time contributors. 🙏 help-wanted

Comments

@kvnkusch
Copy link

Intended outcome:
Setting the defaultOptions on an ApolloClient instance to include partialRefetch: true.

const client = new ApolloClient({
  link,
  cache,
  defaultOptions: {
    query: {
      partialRefetch: true
    }
  }
});

According to this issue this should be possible:
apollographql/apollo-feature-requests#172

Actual outcome:
The above failed typechecks, the relevant types are:

export interface DefaultOptions {
    watchQuery?: Partial<WatchQueryOptions>;
    query?: Partial<QueryOptions>;
    mutate?: Partial<MutationOptions>;
}

export interface QueryOptions<TVariables = OperationVariables> extends QueryBaseOptions<TVariables> {
    fetchPolicy?: FetchPolicy;
}

export interface ModifiableWatchQueryOptions<TVariables = OperationVariables> extends QueryBaseOptions<TVariables> {
    pollInterval?: number;
    notifyOnNetworkStatusChange?: boolean;
    returnPartialData?: boolean;
    partialRefetch?: boolean;
}

partialRefetch is included in ModifiableWatchQueryOptions but not QueryOptions, which DefaultOptions references. Is this intentional, and is it actually possible to default partialRefetch to true for all queries?

Versions
@apollo/client@3.0.0-beta.43

@hwillson hwillson added 📚 good-first-issue Issues that are suitable for first-time contributors. 🙏 help-wanted labels May 26, 2020
@Jonathannsegal
Copy link

From what I see it seems like the reason that this is not passing typeschecks is because it is now a default behavior and shouldent need to be defined in default options. It is still interesting that its failing, will keep looking into this.

@DCtheTall
Copy link
Contributor

@hwillson I'd like to write a PR for this if it's available

@DCtheTall
Copy link
Contributor

DCtheTall commented Oct 5, 2020

I think a pretty simple solution is to merge the ModifiableWatchQueryOptions, QueryBaseOptions, and QueryActions types into one? I don't think this would have any consequences outside of src/core/watchQueryOptions.ts

@hwillson
Copy link
Member

This was addressed in #7136 - thanks!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
📚 good-first-issue Issues that are suitable for first-time contributors. 🙏 help-wanted
Projects
None yet
Development

No branches or pull requests

4 participants