aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/99designs/gqlgen/graphql/introspection
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/99designs/gqlgen/graphql/introspection')
-rw-r--r--vendor/github.com/99designs/gqlgen/graphql/introspection/introspection.go52
-rw-r--r--vendor/github.com/99designs/gqlgen/graphql/introspection/type.go18
2 files changed, 41 insertions, 29 deletions
diff --git a/vendor/github.com/99designs/gqlgen/graphql/introspection/introspection.go b/vendor/github.com/99designs/gqlgen/graphql/introspection/introspection.go
index baff882e..ca0b065f 100644
--- a/vendor/github.com/99designs/gqlgen/graphql/introspection/introspection.go
+++ b/vendor/github.com/99designs/gqlgen/graphql/introspection/introspection.go
@@ -12,19 +12,17 @@ type (
}
EnumValue struct {
- Name string
- Description string
- IsDeprecated bool
- DeprecationReason string
+ Name string
+ Description string
+ deprecation *ast.Directive
}
Field struct {
- Name string
- Description string
- Type *Type
- Args []InputValue
- IsDeprecated bool
- DeprecationReason string
+ Name string
+ Description string
+ Type *Type
+ Args []InputValue
+ deprecation *ast.Directive
}
InputValue struct {
@@ -39,20 +37,36 @@ func WrapSchema(schema *ast.Schema) *Schema {
return &Schema{schema: schema}
}
-func isDeprecated(directives ast.DirectiveList) bool {
- return directives.ForName("deprecated") != nil
+func (f *EnumValue) IsDeprecated() bool {
+ return f.deprecation != nil
+}
+
+func (f *EnumValue) DeprecationReason() *string {
+ if f.deprecation == nil {
+ return nil
+ }
+
+ reason := f.deprecation.Arguments.ForName("reason")
+ if reason == nil {
+ return nil
+ }
+
+ return &reason.Value.Raw
+}
+
+func (f *Field) IsDeprecated() bool {
+ return f.deprecation != nil
}
-func deprecationReason(directives ast.DirectiveList) string {
- deprecation := directives.ForName("deprecated")
- if deprecation == nil {
- return ""
+func (f *Field) DeprecationReason() *string {
+ if f.deprecation == nil {
+ return nil
}
- reason := deprecation.Arguments.ForName("reason")
+ reason := f.deprecation.Arguments.ForName("reason")
if reason == nil {
- return ""
+ return nil
}
- return reason.Value.Raw
+ return &reason.Value.Raw
}
diff --git a/vendor/github.com/99designs/gqlgen/graphql/introspection/type.go b/vendor/github.com/99designs/gqlgen/graphql/introspection/type.go
index dce144e0..b963aa0e 100644
--- a/vendor/github.com/99designs/gqlgen/graphql/introspection/type.go
+++ b/vendor/github.com/99designs/gqlgen/graphql/introspection/type.go
@@ -81,12 +81,11 @@ func (t *Type) Fields(includeDeprecated bool) []Field {
}
fields = append(fields, Field{
- Name: f.Name,
- Description: f.Description,
- Args: args,
- Type: WrapTypeFromType(t.schema, f.Type),
- IsDeprecated: isDeprecated(f.Directives),
- DeprecationReason: deprecationReason(f.Directives),
+ Name: f.Name,
+ Description: f.Description,
+ Args: args,
+ Type: WrapTypeFromType(t.schema, f.Type),
+ deprecation: f.Directives.ForName("deprecated"),
})
}
return fields
@@ -150,10 +149,9 @@ func (t *Type) EnumValues(includeDeprecated bool) []EnumValue {
var res []EnumValue
for _, val := range t.def.EnumValues {
res = append(res, EnumValue{
- Name: val.Name,
- Description: val.Description,
- IsDeprecated: isDeprecated(val.Directives),
- DeprecationReason: deprecationReason(val.Directives),
+ Name: val.Name,
+ Description: val.Description,
+ deprecation: val.Directives.ForName("deprecated"),
})
}
return res