Skip to content

Commit

Permalink
supporting two new fields for __InputValue (#614)
Browse files Browse the repository at this point in the history
  • Loading branch information
pugovok authored Apr 20, 2023
1 parent 477a8d8 commit f0f4e10
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 0 deletions.
28 changes: 28 additions & 0 deletions example/social/introspect.json
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,34 @@
"name": "String",
"ofType": null
}
},
{
"args": [],
"deprecationReason": null,
"description": null,
"isDeprecated": false,
"name": "isDeprecated",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
}
},
{
"args": [],
"deprecationReason": null,
"description": null,
"isDeprecated": false,
"name": "deprecationReason",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
}
],
"inputFields": null,
Expand Down
28 changes: 28 additions & 0 deletions example/starwars/introspect.json
Original file line number Diff line number Diff line change
Expand Up @@ -1694,6 +1694,34 @@
"name": "String",
"ofType": null
}
},
{
"args": [],
"deprecationReason": null,
"description": null,
"isDeprecated": false,
"name": "isDeprecated",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
}
},
{
"args": [],
"deprecationReason": null,
"description": null,
"isDeprecated": false,
"name": "deprecationReason",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
}
],
"inputFields": null,
Expand Down
2 changes: 2 additions & 0 deletions internal/schema/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ var metaSrc = `
type: __Type!
# A GraphQL-formatted string representing the default value for this input value.
defaultValue: String
isDeprecated: Boolean!
deprecationReason: String
}
# A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all
Expand Down
13 changes: 13 additions & 0 deletions introspection/introspection.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,19 @@ func (r *InputValue) DefaultValue() *string {
return &s
}

func (r *InputValue) IsDeprecated() bool {
return r.value.Directives.Get("deprecated") != nil
}

func (r *InputValue) DeprecationReason() *string {
d := r.value.Directives.Get("deprecated")
if d == nil {
return nil
}
reason := d.Arguments.MustGet("reason").Deserialize(nil).(string)
return &reason
}

type EnumValue struct {
value *ast.EnumValueDefinition
}
Expand Down

0 comments on commit f0f4e10

Please sign in to comment.