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

Query variable definitions are dropped when used in a nested query #620

Closed
sambs opened this issue Sep 6, 2016 · 7 comments
Closed

Query variable definitions are dropped when used in a nested query #620

sambs opened this issue Sep 6, 2016 · 7 comments
Labels
Milestone

Comments

@sambs
Copy link

sambs commented Sep 6, 2016

It seems that if query variables are used in a nested way such as this:

query MyQuery($search:String!) {
  spaces(query:{search:$search}) {
    count
  }
}

...then they're dropped from the executed query which ends up looking like this:

query MyQuery {
  spaces(query:{search:$search}) {
    count
  }
}
@sambs
Copy link
Author

sambs commented Sep 6, 2016

I've tried rolling back version by version and this issue was introduced in 0.4.12.

@helfer
Copy link
Contributor

helfer commented Sep 6, 2016

@sambs oh, interesting. Thanks! Can you make a PR with a failing test for this? That would help getting it fixed faster.

@stubailo
Copy link
Contributor

stubailo commented Sep 6, 2016

This is because of the traversal we built for #518, but #615 would remove the need for it altogether.

@danielgriese
Copy link

Hi there,

Any idea when this would be resolved?

While evaluating Apollo for our products, I encountered the same problem by trying to use parameters lower in the query tree (which is totally fine by GraphQL)...

query getLabels($account: String!, $search: String) {
  account(id: $account) {
    labels(search: $search) {
      total
      cursor
      items {
        id
        name
      }
    }
  }
}

This resulted in the issue that Apollo did only send query getLabels($account: String!) and omitted the $search param, which then resulted in an issue from the server saying that $search is not a defined as a variable...

I have a workaround in place including a dummy "root" query that accepts all the variables that I might need. This works, but I don't think I need to tell you who dirty this feels ;) And I most certainly don't want to push this too production now...

query getLabels($account: String!, $search: String) {
  account(id: $account) {
    labels(search: $search) {
    ...
  }

  dummy(search: $search)
}

Thanks and kind regards,
Daniel

@helfer
Copy link
Contributor

helfer commented Sep 21, 2016

@danielgriese We're going to remove query diffing pretty soon (timeframe: less than a week). I'll make sure we take care of this bug as well when we do.

@stubailo
Copy link
Contributor

Discussion here: #615, implementation started here: #693

@stubailo stubailo modified the milestone: New API/Refactor Sep 29, 2016
@stubailo
Copy link
Contributor

Should be fixed in 0.5.0-1.

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

No branches or pull requests

4 participants