github.com/apipluspower/gqlgen@v0.15.2/graphql/introspection/introspection.go (about) 1 // introspection implements the spec defined in https://github.com/facebook/graphql/blob/master/spec/Section%204%20--%20Introspection.md#schema-introspection 2 package introspection 3 4 import "github.com/vektah/gqlparser/v2/ast" 5 6 type ( 7 Directive struct { 8 Name string 9 Description string 10 Locations []string 11 Args []InputValue 12 IsRepeatable bool 13 } 14 15 EnumValue struct { 16 Name string 17 Description string 18 deprecation *ast.Directive 19 } 20 21 Field struct { 22 Name string 23 Description string 24 Type *Type 25 Args []InputValue 26 deprecation *ast.Directive 27 } 28 29 InputValue struct { 30 Name string 31 Description string 32 DefaultValue *string 33 Type *Type 34 } 35 ) 36 37 func WrapSchema(schema *ast.Schema) *Schema { 38 return &Schema{schema: schema} 39 } 40 41 func (f *EnumValue) IsDeprecated() bool { 42 return f.deprecation != nil 43 } 44 45 func (f *EnumValue) DeprecationReason() *string { 46 if f.deprecation == nil { 47 return nil 48 } 49 50 reason := f.deprecation.Arguments.ForName("reason") 51 if reason == nil { 52 return nil 53 } 54 55 return &reason.Value.Raw 56 } 57 58 func (f *Field) IsDeprecated() bool { 59 return f.deprecation != nil 60 } 61 62 func (f *Field) DeprecationReason() *string { 63 if f.deprecation == nil { 64 return nil 65 } 66 67 reason := f.deprecation.Arguments.ForName("reason") 68 if reason == nil { 69 return nil 70 } 71 72 return &reason.Value.Raw 73 }