You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue
Using either loader or gql from this package breaks apollo-client's query deduplication.
Steps to Recreate
In two different components, fire the exact same query by either importing the same .graphql file with loader, or defining the same query with gql from this package. Render both components together, and you will see two network requests fire.
Expectation
If you do the same as the above but with gql from the graphql-tag package, Apollo recognizes that the two queries are the same, and only fires one network request. Could be related to apollographql/apollo-client#4930
Queries are deduplicated only according to the object reference of the DocumentNode.
I imagine this package is returning a different DocumentNode every time the query is imported / defined rather than building up a cache of already-compiled queries and check against that.
Is caching something that's in scope for this package?
The text was updated successfully, but these errors were encountered:
For anyone else that comes by, my solution here was to configure Rescripts and use graphql-tag instead of this package.
You'll also require jest-transform-graphql if you're running tests against code that imports graphql files. This issue helped me correctly configure it for Jest.
Once you've done the above, you can simply import query from 'somewhere.graphql', and because graphql-tag caches correctly, Apollo Client's deduplication works as expected, and only one of the identical queries fires at a time.
Issue
Using either loader or gql from this package breaks apollo-client's query deduplication.
Steps to Recreate
In two different components, fire the exact same query by either importing the same .graphql file with
loader
, or defining the same query withgql
from this package. Render both components together, and you will see two network requests fire.Expectation
If you do the same as the above but with
gql
from thegraphql-tag
package, Apollo recognizes that the two queries are the same, and only fires one network request. Could be related to apollographql/apollo-client#4930Queries are deduplicated only according to the object reference of the DocumentNode
.I imagine this package is returning a different DocumentNode every time the query is imported / defined rather than building up a cache of already-compiled queries and check against that.
Is caching something that's in scope for this package?
The text was updated successfully, but these errors were encountered: