Skip to content

Using fragments without specifying unique name #1109

Answered by kitten
saivanji asked this question in Q&A
Discussion options

You must be logged in to vote

Basically this restriction only exists in GraphQL Tag and what they were meaning to do is disallow fragments from being created that accidentally have the same name in the same query. However, it's completely fine to create some fragments that have the same name if they're not being used in the same query.

So the solution here would be that you could also just use parse from 'graphql'. It depends on your use-case, hence we've used that placeholder name in the example snippets.

It's also possible however to call disableFragmentWarnings from graphql-tag to prevent these warnings: https://github.com/apollographql/graphql-tag/blob/fbbb02e53de7e8a9a9d849ed2ee306d4d0599bfb/src/index.js#L176

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by saivanji
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants