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

Warning: fragment with name X already exists #1757

Open
MetRonnie opened this issue Apr 16, 2024 · 1 comment
Open

Warning: fragment with name X already exists #1757

MetRonnie opened this issue Apr 16, 2024 · 1 comment
Milestone

Comments

@MetRonnie
Copy link
Member

MetRonnie commented Apr 16, 2024

We get a lot of these warnings from graphql-tag in the console:

index.ts:46 Warning: fragment with name AddedDelta already exists.
graphql-tag enforces all fragment names across your application to be unique; read more about
this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names

(The link in the warning is dead)

From apollographql/graphql-tag#269:

we have a global module cache... of the fragments we parse — that means that somewhere else in your application, there's another fragment defined with the same name. we protect against this because if you were to interpolate both of them into the same GraphQL document, it would fail validation. you can disable this warning by invoking disableFragmentWarnings ( https://github.com/apollographql/graphql-tag#warnings )

However we also get this warning for fragments defined only once in the whole app, because at

// And here we set the new merged-query. Voila!
// NOTE: we-recreate the gql object because it contains derived attributes
// which may only get updated by doing this
// see https://github.com/cylc/cylc-ui/issues/1110
subscription.query.query = gql(print(finalQuery))

it is re-evaluating the fragment definitions (which have already been cached the first time) each time the query changes because they are included in the query document.

@MetRonnie MetRonnie added this to the 2.x milestone Apr 16, 2024
@oliver-sanders
Copy link
Member

oliver-sanders commented Apr 16, 2024

At present fragments must be given the same name in order to merge, this isn't a problem because we merge them before issuing the request. Presumably these warnings are being raised during the merging process not at request time?

We could potentially avoid the whole merging process by generating the subscription on demand, this solution is outlined here: #862 (comment)

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

No branches or pull requests

2 participants