Skip to content

Commit f0f4e10

Browse files
authored
supporting two new fields for __InputValue (#614)
https://spec.graphql.org/draft/#sec-Type-Name-Introspection
1 parent 477a8d8 commit f0f4e10

File tree

4 files changed

+71
-0
lines changed

4 files changed

+71
-0
lines changed

example/social/introspect.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,34 @@
10521052
"name": "String",
10531053
"ofType": null
10541054
}
1055+
},
1056+
{
1057+
"args": [],
1058+
"deprecationReason": null,
1059+
"description": null,
1060+
"isDeprecated": false,
1061+
"name": "isDeprecated",
1062+
"type": {
1063+
"kind": "NON_NULL",
1064+
"name": null,
1065+
"ofType": {
1066+
"kind": "SCALAR",
1067+
"name": "Boolean",
1068+
"ofType": null
1069+
}
1070+
}
1071+
},
1072+
{
1073+
"args": [],
1074+
"deprecationReason": null,
1075+
"description": null,
1076+
"isDeprecated": false,
1077+
"name": "deprecationReason",
1078+
"type": {
1079+
"kind": "SCALAR",
1080+
"name": "String",
1081+
"ofType": null
1082+
}
10551083
}
10561084
],
10571085
"inputFields": null,

example/starwars/introspect.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,6 +1694,34 @@
16941694
"name": "String",
16951695
"ofType": null
16961696
}
1697+
},
1698+
{
1699+
"args": [],
1700+
"deprecationReason": null,
1701+
"description": null,
1702+
"isDeprecated": false,
1703+
"name": "isDeprecated",
1704+
"type": {
1705+
"kind": "NON_NULL",
1706+
"name": null,
1707+
"ofType": {
1708+
"kind": "SCALAR",
1709+
"name": "Boolean",
1710+
"ofType": null
1711+
}
1712+
}
1713+
},
1714+
{
1715+
"args": [],
1716+
"deprecationReason": null,
1717+
"description": null,
1718+
"isDeprecated": false,
1719+
"name": "deprecationReason",
1720+
"type": {
1721+
"kind": "SCALAR",
1722+
"name": "String",
1723+
"ofType": null
1724+
}
16971725
}
16981726
],
16991727
"inputFields": null,

internal/schema/meta.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ var metaSrc = `
148148
type: __Type!
149149
# A GraphQL-formatted string representing the default value for this input value.
150150
defaultValue: String
151+
isDeprecated: Boolean!
152+
deprecationReason: String
151153
}
152154
153155
# A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all

introspection/introspection.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,19 @@ func (r *InputValue) DefaultValue() *string {
270270
return &s
271271
}
272272

273+
func (r *InputValue) IsDeprecated() bool {
274+
return r.value.Directives.Get("deprecated") != nil
275+
}
276+
277+
func (r *InputValue) DeprecationReason() *string {
278+
d := r.value.Directives.Get("deprecated")
279+
if d == nil {
280+
return nil
281+
}
282+
reason := d.Arguments.MustGet("reason").Deserialize(nil).(string)
283+
return &reason
284+
}
285+
273286
type EnumValue struct {
274287
value *ast.EnumValueDefinition
275288
}

0 commit comments

Comments
 (0)