apollographql / graphql-tag

A JavaScript template literal tag that parses GraphQL queries
MIT License
2.32k stars 175 forks source link

Warnings are being emitted if you have multiple fragments of the same name for different servers #810

Open Tri125 opened 10 months ago

Tri125 commented 10 months ago
Warning: fragment with name Cake 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

My application is communicating with different graphql servers, their graphs are not related but they use similarly named types and fields, leading to similarly named fragments.

Is there a mechanism to scope the detection so that fragment "Cake" for server A doesn't generate a warning when there's a fragment "Cake" for server B?

I can work around it by renaming the fragments (CakeA, CakeB) which is less than ideal but I'm wondering if that's a use case that's been thought over.

Calling disableFragmentWarnings(); is undesirable as I still want to be warned if 2 fragments named "Cake" are both defined for the same server.