Skip to content

Commit c0c2f5e

Browse files
committed
Add unique-names anchor to fragments docs so graphql-tag warning links resolve
The graphql-tag library warns when duplicate fragment names are found and links to http://dev.apollodata.com/core/fragments.html#unique-names. This URL no longer resolves. Add a dedicated section with the {#unique-names} custom anchor ID to the Apollo Client fragments docs page so the link serves useful content instead of a 404. Fixes #13292
1 parent 544daab commit c0c2f5e

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

.changeset/quiet-pans-doubt.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@apollo/client": patch
3+
---
4+
5+
Add `{#unique-names}` anchor to the fragments docs page so the `graphql-tag` warning about duplicate fragment names links to a valid page.

docs/source/data/fragments.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ query GetPerson {
4141

4242
Changes to the `NameParts` fragment automatically update the fields included in any operations that use it. This reduces the effort required to keep fields consistent across a set of operations.
4343

44+
## Unique fragment names {#unique-names}
45+
46+
Fragment names must be unique across your entire application. If you accidentally define two fragments with the same name but different field selections, `graphql-tag` warns you about the conflict at runtime to prevent subtle bugs:
47+
48+
```text
49+
Warning: fragment with name SomeFragment already exists.
50+
graphql-tag enforces all fragment names across your application to be unique; read more about
51+
this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names
52+
```
53+
54+
Always use descriptive, component-scoped fragment names (like `ItemFragment` or `UserProfileFragment`) to avoid accidental name collisions.
55+
4456
## Example usage
4557

4658
Let's say we have a blog application that executes several GraphQL operations related to comments (submitting a comment, fetching a post's comments, etc.). Our application likely has a `Comment` component that is responsible for rendering comment data.

0 commit comments

Comments
 (0)