Skip to content

Infinite loop when using directives #2243

Closed
@santaclauze

Description

@santaclauze

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions