Skip to content
52 changes: 44 additions & 8 deletions spec/Section 3 -- Type System.md
Original file line number Diff line number Diff line change
Expand Up @@ -1089,20 +1089,41 @@ In this example, a directive is added to a `User` type without adding fields:
extend type User @addedDirective
```

Object type extensions may choose to extend existing fields.

In this example, we can deprecate the field `id` on type `Query` by adding a
`@deprecated` directive through a type extension:

```graphql example
type Query {
id: String
}
```

```graphql example
extend type Query {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this world, extend is a keyword for merge?

id: String @deprecated(reason: "Use newId")
}
```

**Type Validation**

Object type extensions have the potential to be invalid if incorrectly defined.

1. The named type must already be defined and must be an Object type.
2. The fields of an Object type extension must have unique names; no two fields
may share the same name.
3. Any fields of an Object type extension must not be already defined on the
previous Object type.
4. Any non-repeatable directives provided must not already apply to the previous
2. For each field of an Object type extension:
1. The field must have a unique name within that Object type extension; no
two fields may share the same name.
2. If a field with the same name exists on the previous Object type:
1. The field type must match the previous definition exactly.
2. The argument definitions defaultValues must match.
3. The description or deprecation may be added if none exists, or must
match the existing description or deprecation exactly.
4. Directives may be added but cannot conflict with existing
non-repeatable directives.
3. Any interfaces provided must not be already implemented by the previous
Object type.
5. Any interfaces provided must not be already implemented by the previous
Object type.
6. The resulting extended object type must be a super-set of all interfaces it
4. The resulting extended object type must be a super-set of all interfaces it
implements.

## Interfaces
Expand Down Expand Up @@ -1358,6 +1379,21 @@ defined.
6. The resulting extended Interface type must be a super-set of all Interfaces
it implements.

#### Interface Field Extensions

Interface field extensions follow the same rules as Object field extensions and
are used to extend fields on interface types.

```graphql example
interface Node {
id: ID
}

extend interface Node {
id: ID @deprecated(reason: "Use globalId instead")
}
```

## Unions

UnionTypeDefinition : Description? union Name Directives[Const]?
Expand Down