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

useQuery argument null exception when query is null/undefined and skip is true #7021

Closed
MichaelBurgess opened this issue Sep 15, 2020 · 2 comments

Comments

@MichaelBurgess
Copy link

MichaelBurgess commented Sep 15, 2020

In 3.1.5 I could do something like this:

const getQuery = (type) => {
  if (type === "foo") {
    return fooQuery;
  }
  if (type === "bar") {
    return barQuery;
  }
  return null;
}

// type will eventually get a non-null value, but will initially be null
const query = getQuery(type);

// skip until the query is determined
const { error, loading, data } = useQuery(query, {
  skip: !query,
});

In this example, I don't know what query to use until I have a value for type, therefore the query is skipped until I do.

This worked fine in 3.1.5, but in 3.2.0 I now get this:

Argument of null passed to parser was not a valid GraphQL DocumentNode. You may need to use 'graphql-tag' or another method to convert your operation into a document.

I don't see anything in the release notes documenting this change, so unsure if it was intentional, or a side-effect of something else?

Initially I thought this was the skip issue again as per #6190 (comment), but it seems a little different now?

System:
  OS: macOS 10.15.6
Binaries:
  Node: 14.10.1 - /usr/local/bin/node
  Yarn: 1.22.5 - /usr/local/bin/yarn
  npm: 6.14.8 - /usr/local/bin/npm
Browsers:
  Chrome: 85.0.4183.102
  Firefox: 80.0.1
  Safari: 13.1.2
npmPackages:
  @apollo/client: 3.2.0 => 3.2.0
@MichaelBurgess MichaelBurgess changed the title useQuery argument null exception in 3.2.0 when query is null and skip is true useQuery argument null exception in 3.2.0 when query is null/undefined and skip is true Sep 15, 2020
@MichaelBurgess MichaelBurgess changed the title useQuery argument null exception in 3.2.0 when query is null/undefined and skip is true useQuery argument null exception when query is null/undefined and skip is true Sep 15, 2020
@msjonker
Copy link

Looks like this was caused by #6999

@hwillson
Copy link
Member

It doesn't sound like there is an outstanding issue here, so closing. 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
None yet
Projects
None yet
Development

No branches or pull requests

3 participants