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

useLazyQuery ignores changes to the query document #10496

Closed
laytong opened this issue Jan 30, 2023 · 2 comments · Fixed by #10499
Closed

useLazyQuery ignores changes to the query document #10496

laytong opened this issue Jan 30, 2023 · 2 comments · Fixed by #10499

Comments

@laytong
Copy link

laytong commented Jan 30, 2023

Issue Description

Despite what the documentation for useLazyQuery appears to suggest. Updating the "Query" option inside the trigger of the lazyQuery does nothing.

i.e.
const [fetchMyQuery] = useLazyQuery(QUERY_1)

and later calling fetchMyQuery({ query: SOME_OTHER_QUERY}) still calls QUERY_1

Link to Reproduction

https://codesandbox.io/embed/great-mestorf-f9nmze?fontsize=14&hidenavigation=1&theme=dark

Reproduction Steps

useLazyQuery with a default gql query,

Override it

The original query is executed and changes are ignored.

@jerelmiller
Copy link
Member

jerelmiller commented Jan 30, 2023

Hey @laytong 👋

This looks related to #10198, just used in a slightly different way. Seeing as useQuery supports the ability to swap queries, I see no reason this shouldn't either.

I can't guarantee a time frame on a fix, but we will try to get to this when we can! Feel free to submit a PR if you're interested in fixing yourself and we'd be happy to review it 🙂

phryneas added a commit to phryneas/apollo-client that referenced this issue Feb 1, 2023
phryneas added a commit to phryneas/apollo-client that referenced this issue Feb 1, 2023
@alessbell alessbell assigned phryneas and unassigned alessbell Feb 1, 2023
phryneas added a commit that referenced this issue Feb 1, 2023
* Allow `useLazyQuery` trigger fn to change `query`
fixes #10496

* bump bundle size limit by a smidgen

* Update .changeset/seven-cameras-kiss.md

Co-authored-by: Jerel Miller <jerelmiller@gmail.com>

---------

Co-authored-by: Jerel Miller <jerelmiller@gmail.com>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2023

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
For general questions, we recommend using StackOverflow or our discord server.

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

Successfully merging a pull request may close this issue.

4 participants