Skip to content

Commit

Permalink
Add language to ensure fragments are unique within a document
Browse files Browse the repository at this point in the history
  • Loading branch information
leebyron committed Aug 7, 2015
1 parent 750d4ee commit 994ba71
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions spec/Section 5 -- Validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,60 @@ fragment missingRequiredArg on Arguments {

### Fragment Declarations

#### Fragment Name Uniqueness

** Formal Specification **

* For each fragment definition {fragment} in the document
* Let {fragmentName} be the name of {fragment}.
* Let {fragments} be all fragment definitions in the document named {fragmentName}.
* {fragments} must be a set of one.

** Explanatory Text **

Fragment definitions are referenced in fragment spreads by name. To avoid
ambiguity, each fragment's name must be unique within a document.

Inline fragments are not considered fragment definitions, and unaffected by this
validation rule.

For example the following document is valid:

```graphql
{
...fragmentOne
...fragmentTwo
}

fragment fragmentOne on Dog {
name
}

fragment fragmentTwo on Dog {
owner {
name
}
}
```

While this document is invalid:

```graphql
{
...fragmentOne
}

fragment fragmentOne on Dog {
name
}

fragment fragmentOne on Dog {
owner {
name
}
}
```

#### Fragment Spread Type Existence

** Formal Specification **
Expand Down

0 comments on commit 994ba71

Please sign in to comment.