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

Infinite loop when using directives #2243

Closed
santaclauze opened this issue Nov 1, 2019 · 1 comment
Closed

Infinite loop when using directives #2243

santaclauze opened this issue Nov 1, 2019 · 1 comment
Labels

Comments

@santaclauze
Copy link

First of all thanks for the great project. I use graphql a lot and am trying to look in the deeper functionalities.

I have a large entity that I query in multiple places in my app. I realized I could query only parts of it by using directives.

In one of my components, I have to query within a useEffect and thus opted for the lazy query.

Screen Shot 2019-11-01 at 5 59 13 PM

Screen Shot 2019-11-01 at 5 59 54 PM

I then added directives as follows:

Screen Shot 2019-11-01 at 6 00 43 PM
Screen Shot 2019-11-01 at 6 00 51 PM

When loggin on my app, I get an infinite loop that keep triggering the lazyQuery even though the directive arguments seem to be set.

Screen Shot 2019-11-01 at 6 02 22 PM

HOWEVER, As soon as I add the arguments as follows, it fixes the infinite loop.

Screen Shot 2019-11-01 at 6 03 38 PM

Is there something in the behaviour of Graphql that I am missing? is this an expected behaviour?

It seems quite odd to me that passing the variables in the query even though they were visible in teh query before and being set with a default value would give any different result.

@IvanGoncharov
Copy link
Member

@santaclauze Sorry for the delay, I was traveling to/from GraphQL Summit ✈️
Looks like you are using Apollo on your frontend?
graphql-js has no relationship to React or frontend frameworks in general so I recommend reporting it here: https://github.com/apollographql/apollo-client

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants