diff --git a/types/introspection-field.go b/types/introspection-field.go index 8f8c1d4..16b212a 100644 --- a/types/introspection-field.go +++ b/types/introspection-field.go @@ -1,4 +1,11 @@ package types +// IntrospectionField represents a field in a GraphQL object or interface type. type IntrospectionField struct { + Name string `json:"name"` + Description string `json:"description"` + Args []IntrospectionInputValue `json:"args"` + Type IntrospectionInputTypeRef `json:"type"` + IsDeprecated bool `json:"isDeprecated"` + DeprecationReason string `json:"deprecationReason"` } diff --git a/types/introspection-schema.go b/types/introspection-schema.go index 687ebbc..4cd6c28 100644 --- a/types/introspection-schema.go +++ b/types/introspection-schema.go @@ -5,6 +5,6 @@ type IntrospectionSchema struct { QueryType IntrospectionObjectType `json:"queryType"` MutationType IntrospectionObjectType `json:"mutationType"` SubscriptionType IntrospectionObjectType `json:"subscriptionType"` - Types IntrospectionType `json:"types"` + Types []IntrospectionType `json:"types"` Directives []IntrospectionDirective `json:"directives"` } diff --git a/types/introspection-type.go b/types/introspection-type.go index 01b6128..6ddb252 100644 --- a/types/introspection-type.go +++ b/types/introspection-type.go @@ -10,41 +10,54 @@ type IntrospectionScalarType struct { SpecifiedByURL string `json:"specifiedByURL"` } +// TypeRef represents a reference to a type in the schema +type TypeRef struct { + Name string `json:"name"` + Kind string `json:"kind"` +} + type IntrospectionObjectType struct { - Kind string `json:"kind"` - Name string `json:"name"` - Description string `json:"description"` - Fields IntrospectionField `json:"fields"` - Interfaces interface{} `json:"interfaces"` + Kind string `json:"kind"` + Name string `json:"name"` + Description string `json:"description"` + Fields []IntrospectionField `json:"fields"` + Interfaces []TypeRef `json:"interfaces"` } type IntrospectionInterfaceType struct { - Kind string `json:"kind"` - Name string `json:"name"` - Description string `json:"description"` - Fields IntrospectionField `json:"fields"` - Interfaces interface{} `json:"interfaces"` - // possibleTypes IntrospectionObjectType `json:"possibleTypes"` + Kind string `json:"kind"` + Name string `json:"name"` + Description string `json:"description"` + Fields []IntrospectionField `json:"fields"` + Interfaces []TypeRef `json:"interfaces"` + PossibleTypes []TypeRef `json:"possibleTypes"` } type IntrospectionUnionType struct { - Kind string `json:"kind"` - Name string `json:"name"` - Description string `json:"description"` - PossibleTypes IntrospectionObjectType `json:"possibleTypes"` + Kind string `json:"kind"` + Name string `json:"name"` + Description string `json:"description"` + PossibleTypes []TypeRef `json:"possibleTypes"` +} + +type IntrospectionEnumValue struct { + Name string `json:"name"` + Description string `json:"description"` + IsDeprecated bool `json:"isDeprecated"` + DeprecationReason string `json:"deprecationReason"` } type IntrospectionEnumType struct { - Kind string `json:"kind"` - Name string `json:"name"` - Description string `json:"description"` - // enumValues IntrospectionEnumValue `json:"enumValues"` + Kind string `json:"kind"` + Name string `json:"name"` + Description string `json:"description"` + EnumValues []IntrospectionEnumValue `json:"enumValues"` } type IntrospectionInputObjectType struct { - Kind string `json:"kind"` - Name string `json:"name"` - Description string `json:"description"` - // inputFields IntrospectionInputValue `json:"inputFields"` - IsOneOf bool `json:"isOneOf"` + Kind string `json:"kind"` + Name string `json:"name"` + Description string `json:"description"` + InputFields []IntrospectionInputValue `json:"inputFields"` + IsOneOf bool `json:"isOneOf"` }