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

Feature idea: conditional refetchQueries #2143

Closed
trevordmiller opened this issue Sep 11, 2017 · 8 comments
Closed

Feature idea: conditional refetchQueries #2143

trevordmiller opened this issue Sep 11, 2017 · 8 comments
Milestone

Comments

@trevordmiller
Copy link

Currently, Apollo outputs a unknown query with name {Query} asked to refetch warning whenever a mutation is run that has a refetchQuery that hasn't been run yet (which occurs often, since users can start on different routes).

image

It would be great if refetchQuery only ran if the related query has already run at least once instead of showing this warning.

I'm using the query name as a string for the refetchQueries arg like:

  graphql(
    gql`
      mutation {
        someMutation {
          someField
        }
      }
    `,
    {
      options: {
        refetchQueries: ['SomeQuery', 'AnotherQuery'],
      },
    }
  ),
@trevordmiller
Copy link
Author

@stubailo, @helfer any thoughts on this? Is there something I'm missing? Thank you so much for your great work, apollo-client is fantastic!

@ghost
Copy link

ghost commented Oct 6, 2017

I am also experiencing the same thing. They are not errors and I still have the intended side effect; the yellow warning line is jut annoying :(

@jbaxleyiii
Copy link
Contributor

hmm, this is an interesting issue. I'll see if I can improve this with the 2.0 or immediately following. Do you have a sample app / reproduction I can use to see this?

@jbaxleyiii jbaxleyiii added this to the 2.0 milestone Oct 10, 2017
@trevordmiller
Copy link
Author

@jbaxleyiii That would be fantastic, thank you. I don't have a sample app, but to reproduce just make some route-level components that use refetchQueries like this:

graphql(
  gql`
    mutation {
      someMutation {
        someField
      }
    }
  `,
  {
    options: {
      refetchQueries: ['SomeQuery', 'AnotherQuery'],
    },
  }
),

Then refresh the app at different routes and the routes with refetchQueries for other routes will throw the errors.

@jbaxleyiii
Copy link
Contributor

@trevordmiller so the warnings are there as a help to prevent things like one off spelling mistakes where you are trying to update a query but it doesn't exist yet. I think I understand the use case you have though to generically try and refetch a few possible queries even if they haven't been run yet.

I think its probably best to remove the warning since the use case is more important to support than warnings for mistaken code

@ghost
Copy link

ghost commented Oct 11, 2017

The verbatim warning that it throws is:

Warning: unknown query with name <query name in refetch array> asked to refetch

I also think that just removing this warning will sort this because everything works fine and it doesn't stop or crash anything, it's just that the yellow warning line stacks up on React Native (iOS simulator). :)

@jbaxleyiii jbaxleyiii modified the milestones: 2.0, Post 2.0 Oct 11, 2017
@jbaxleyiii
Copy link
Contributor

Fixed in what will be beta-7 #2281

@trevordmiller
Copy link
Author

@jbaxleyiii Thank you so much!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants