diff options
author | Michael Muré <batolettre@gmail.com> | 2020-02-05 22:03:19 +0100 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2020-02-05 22:33:03 +0100 |
commit | 1d4bb7ceb0cef79d68df0bacc913b01e40e6ddd6 (patch) | |
tree | e088b0fa43058afde1db71541d8fcb4b94905d6e /vendor/github.com/99designs/gqlgen/graphql/introspection | |
parent | f093be96e98284580d61664adecd0a2ff8b354e4 (diff) | |
download | git-bug-1d4bb7ceb0cef79d68df0bacc913b01e40e6ddd6.tar.gz |
migrate to go modules
Diffstat (limited to 'vendor/github.com/99designs/gqlgen/graphql/introspection')
4 files changed, 0 insertions, 420 deletions
diff --git a/vendor/github.com/99designs/gqlgen/graphql/introspection/introspection.go b/vendor/github.com/99designs/gqlgen/graphql/introspection/introspection.go deleted file mode 100644 index ca0b065f..00000000 --- a/vendor/github.com/99designs/gqlgen/graphql/introspection/introspection.go +++ /dev/null @@ -1,72 +0,0 @@ -// introspection implements the spec defined in https://github.com/facebook/graphql/blob/master/spec/Section%204%20--%20Introspection.md#schema-introspection -package introspection - -import "github.com/vektah/gqlparser/ast" - -type ( - Directive struct { - Name string - Description string - Locations []string - Args []InputValue - } - - EnumValue struct { - Name string - Description string - deprecation *ast.Directive - } - - Field struct { - Name string - Description string - Type *Type - Args []InputValue - deprecation *ast.Directive - } - - InputValue struct { - Name string - Description string - DefaultValue *string - Type *Type - } -) - -func WrapSchema(schema *ast.Schema) *Schema { - return &Schema{schema: schema} -} - -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 (f *Field) DeprecationReason() *string { - if f.deprecation == nil { - return nil - } - - reason := f.deprecation.Arguments.ForName("reason") - if reason == nil { - return nil - } - - return &reason.Value.Raw -} diff --git a/vendor/github.com/99designs/gqlgen/graphql/introspection/query.go b/vendor/github.com/99designs/gqlgen/graphql/introspection/query.go deleted file mode 100644 index b1e4fbc6..00000000 --- a/vendor/github.com/99designs/gqlgen/graphql/introspection/query.go +++ /dev/null @@ -1,104 +0,0 @@ -package introspection - -// Query is the query generated by graphiql to determine type information -const Query = ` -query IntrospectionQuery { - __schema { - queryType { - name - } - mutationType { - name - } - subscriptionType { - name - } - types { - ...FullType - } - directives { - name - description - locations - args { - ...InputValue - } - } - } -} - -fragment FullType on __Type { - kind - name - description - fields(includeDeprecated: true) { - name - description - args { - ...InputValue - } - type { - ...TypeRef - } - isDeprecated - deprecationReason - } - inputFields { - ...InputValue - } - interfaces { - ...TypeRef - } - enumValues(includeDeprecated: true) { - name - description - isDeprecated - deprecationReason - } - possibleTypes { - ...TypeRef - } -} - -fragment InputValue on __InputValue { - name - description - type { - ...TypeRef - } - defaultValue -} - -fragment TypeRef on __Type { - kind - name - ofType { - kind - name - ofType { - kind - name - ofType { - kind - name - ofType { - kind - name - ofType { - kind - name - ofType { - kind - name - ofType { - kind - name - } - } - } - } - } - } - } -} -` diff --git a/vendor/github.com/99designs/gqlgen/graphql/introspection/schema.go b/vendor/github.com/99designs/gqlgen/graphql/introspection/schema.go deleted file mode 100644 index a57272d5..00000000 --- a/vendor/github.com/99designs/gqlgen/graphql/introspection/schema.go +++ /dev/null @@ -1,68 +0,0 @@ -package introspection - -import ( - "strings" - - "github.com/vektah/gqlparser/ast" -) - -type Schema struct { - schema *ast.Schema -} - -func (s *Schema) Types() []Type { - types := make([]Type, 0, len(s.schema.Types)) - for _, typ := range s.schema.Types { - if strings.HasPrefix(typ.Name, "__") { - continue - } - types = append(types, *WrapTypeFromDef(s.schema, typ)) - } - return types -} - -func (s *Schema) QueryType() *Type { - return WrapTypeFromDef(s.schema, s.schema.Query) -} - -func (s *Schema) MutationType() *Type { - return WrapTypeFromDef(s.schema, s.schema.Mutation) -} - -func (s *Schema) SubscriptionType() *Type { - return WrapTypeFromDef(s.schema, s.schema.Subscription) -} - -func (s *Schema) Directives() []Directive { - res := make([]Directive, 0, len(s.schema.Directives)) - - for _, d := range s.schema.Directives { - res = append(res, s.directiveFromDef(d)) - } - - return res -} - -func (s *Schema) directiveFromDef(d *ast.DirectiveDefinition) Directive { - locs := make([]string, len(d.Locations)) - for i, loc := range d.Locations { - locs[i] = string(loc) - } - - args := make([]InputValue, len(d.Arguments)) - for i, arg := range d.Arguments { - args[i] = InputValue{ - Name: arg.Name, - Description: arg.Description, - DefaultValue: defaultValue(arg.DefaultValue), - Type: WrapTypeFromType(s.schema, arg.Type), - } - } - - return Directive{ - Name: d.Name, - Description: d.Description, - Locations: locs, - Args: args, - } -} diff --git a/vendor/github.com/99designs/gqlgen/graphql/introspection/type.go b/vendor/github.com/99designs/gqlgen/graphql/introspection/type.go deleted file mode 100644 index 9aceebdc..00000000 --- a/vendor/github.com/99designs/gqlgen/graphql/introspection/type.go +++ /dev/null @@ -1,176 +0,0 @@ -package introspection - -import ( - "strings" - - "github.com/vektah/gqlparser/ast" -) - -type Type struct { - schema *ast.Schema - def *ast.Definition - typ *ast.Type -} - -func WrapTypeFromDef(s *ast.Schema, def *ast.Definition) *Type { - if def == nil { - return nil - } - return &Type{schema: s, def: def} -} - -func WrapTypeFromType(s *ast.Schema, typ *ast.Type) *Type { - if typ == nil { - return nil - } - - if !typ.NonNull && typ.NamedType != "" { - return &Type{schema: s, def: s.Types[typ.NamedType]} - } - return &Type{schema: s, typ: typ} -} - -func (t *Type) Kind() string { - if t.typ != nil { - if t.typ.NonNull { - return "NON_NULL" - } - - if t.typ.Elem != nil { - return "LIST" - } - } else { - return string(t.def.Kind) - } - - panic("UNKNOWN") -} - -func (t *Type) Name() *string { - if t.def == nil { - return nil - } - return &t.def.Name -} - -func (t *Type) Description() string { - if t.def == nil { - return "" - } - return t.def.Description -} - -func (t *Type) Fields(includeDeprecated bool) []Field { - if t.def == nil || (t.def.Kind != ast.Object && t.def.Kind != ast.Interface) { - return []Field{} - } - fields := []Field{} - for _, f := range t.def.Fields { - if strings.HasPrefix(f.Name, "__") { - continue - } - - if !includeDeprecated && f.Directives.ForName("deprecated") != nil { - continue - } - - var args []InputValue - for _, arg := range f.Arguments { - args = append(args, InputValue{ - Type: WrapTypeFromType(t.schema, arg.Type), - Name: arg.Name, - Description: arg.Description, - DefaultValue: defaultValue(arg.DefaultValue), - }) - } - - fields = append(fields, Field{ - Name: f.Name, - Description: f.Description, - Args: args, - Type: WrapTypeFromType(t.schema, f.Type), - deprecation: f.Directives.ForName("deprecated"), - }) - } - return fields -} - -func (t *Type) InputFields() []InputValue { - if t.def == nil || t.def.Kind != ast.InputObject { - return []InputValue{} - } - - res := []InputValue{} - for _, f := range t.def.Fields { - res = append(res, InputValue{ - Name: f.Name, - Description: f.Description, - Type: WrapTypeFromType(t.schema, f.Type), - DefaultValue: defaultValue(f.DefaultValue), - }) - } - return res -} - -func defaultValue(value *ast.Value) *string { - if value == nil { - return nil - } - val := value.String() - return &val -} - -func (t *Type) Interfaces() []Type { - if t.def == nil || t.def.Kind != ast.Object { - return []Type{} - } - - res := []Type{} - for _, intf := range t.def.Interfaces { - res = append(res, *WrapTypeFromDef(t.schema, t.schema.Types[intf])) - } - - return res -} - -func (t *Type) PossibleTypes() []Type { - if t.def == nil || (t.def.Kind != ast.Interface && t.def.Kind != ast.Union) { - return []Type{} - } - - res := []Type{} - for _, pt := range t.schema.GetPossibleTypes(t.def) { - res = append(res, *WrapTypeFromDef(t.schema, pt)) - } - return res -} - -func (t *Type) EnumValues(includeDeprecated bool) []EnumValue { - if t.def == nil || t.def.Kind != ast.Enum { - return []EnumValue{} - } - - res := []EnumValue{} - for _, val := range t.def.EnumValues { - res = append(res, EnumValue{ - Name: val.Name, - Description: val.Description, - deprecation: val.Directives.ForName("deprecated"), - }) - } - return res -} - -func (t *Type) OfType() *Type { - if t.typ == nil { - return nil - } - if t.typ.NonNull { - // fake non null nodes - cpy := *t.typ - cpy.NonNull = false - - return WrapTypeFromType(t.schema, &cpy) - } - return WrapTypeFromType(t.schema, t.typ.Elem) -} |