Skip to content

Commit 9ef8c9b

Browse files
committed
Implement deprecation for arguments and input fields
graphql/graphql-spec#805 changed the GraphQL spec to allow deprecation on argument definitions and input field definitions.
1 parent 09272f3 commit 9ef8c9b

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

directives.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ var DeprecatedDirective = NewDirective(DirectiveConfig{
143143
},
144144
Locations: []string{
145145
DirectiveLocationFieldDefinition,
146+
DirectiveLocationArgumentDefinition,
147+
DirectiveLocationInputFieldDefinition,
146148
DirectiveLocationEnumValue,
147149
},
148150
})

introspection.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,26 @@ func init() {
275275
return nil, nil
276276
},
277277
},
278+
"isDeprecated": &Field{
279+
Type: NewNonNull(Boolean),
280+
Resolve: func(p ResolveParams) (interface{}, error) {
281+
if field, ok := p.Source.(*FieldDefinition); ok {
282+
return (field.DeprecationReason != ""), nil
283+
}
284+
return false, nil
285+
},
286+
},
287+
"deprecationReason": &Field{
288+
Type: String,
289+
Resolve: func(p ResolveParams) (interface{}, error) {
290+
if field, ok := p.Source.(*FieldDefinition); ok {
291+
if field.DeprecationReason != "" {
292+
return field.DeprecationReason, nil
293+
}
294+
}
295+
return nil, nil
296+
},
297+
},
278298
},
279299
})
280300

0 commit comments

Comments
 (0)