Skip to content

Commit

Permalink
Implement deprecation for arguments and input fields
Browse files Browse the repository at this point in the history
graphql/graphql-spec#805 changed the GraphQL
spec to allow deprecation on argument definitions and input field
definitions.
  • Loading branch information
dchang-dchang committed Aug 22, 2022
1 parent 09272f3 commit 9ef8c9b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions directives.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ var DeprecatedDirective = NewDirective(DirectiveConfig{
},
Locations: []string{
DirectiveLocationFieldDefinition,
DirectiveLocationArgumentDefinition,
DirectiveLocationInputFieldDefinition,
DirectiveLocationEnumValue,
},
})
20 changes: 20 additions & 0 deletions introspection.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,26 @@ func init() {
return nil, nil
},
},
"isDeprecated": &Field{
Type: NewNonNull(Boolean),
Resolve: func(p ResolveParams) (interface{}, error) {
if field, ok := p.Source.(*FieldDefinition); ok {
return (field.DeprecationReason != ""), nil
}
return false, nil
},
},
"deprecationReason": &Field{
Type: String,
Resolve: func(p ResolveParams) (interface{}, error) {
if field, ok := p.Source.(*FieldDefinition); ok {
if field.DeprecationReason != "" {
return field.DeprecationReason, nil
}
}
return nil, nil
},
},
},
})

Expand Down

0 comments on commit 9ef8c9b

Please sign in to comment.