Documentation ¶
Index ¶
- Constants
- func ExpandType(s *Schema, t *Type) (*[]*Type, error)
- func ExpandTypes(s *Schema, types []config.TypeConfig, methods []config.MethodConfig) (*[]*Type, error)
- type EnumValue
- type Field
- type Kind
- type MutationInfo
- type QueryInfo
- type QueryResponse
- type QueryTypeVars
- type Schema
- type SubscriptionInfo
- type Type
- type TypeRef
Constants ¶
const ( // QuerySchema gets basic info about the schema QuerySchema = `query { __schema { mutationType { name } queryType { name } subscriptionType { name } } }` // QuerySchemaTypes is used to fetch all of the data types in the schema QuerySchemaTypes = `query { __schema { types { ...FullType } } }` + " " + fragmentFullType // QueryType returns all of the data on that specific type, useful for fetching queries / mutations QueryType = `query($typeName:String!) { __type(name: $typeName) { ...FullType } }` + " " + fragmentFullType )
https://github.com/graphql/graphql-js/blob/master/src/utilities/getIntrospectionQuery.js#L35
Modified from the following as we only care about the Types query IntrospectionQuery { __schema { directives { name description locations args { ...InputValue } } mutationType { name } queryType { name } subscriptionType { name } types { ...FullType } } }
Variables ¶
This section is empty.
Functions ¶
func ExpandType ¶
ExpandType receives a Type which is used to determine the Type for all nested fields.
func ExpandTypes ¶
func ExpandTypes(s *Schema, types []config.TypeConfig, methods []config.MethodConfig) (*[]*Type, error)
ExpandTypes receives a set of config.TypeConfig, which is then expanded to include all the nested types from the fields.
Types ¶
type EnumValue ¶
type EnumValue struct { Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Kind Kind `json:"kind,omitempty"` IsDeprecated bool `json:"isDeprecated"` DeprecationReason string `json:"deprecationReason"` }
func (*EnumValue) GetDescription ¶
GetDescription formats the description into a GoDoc comment.
type Field ¶
type Field struct { Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Kind Kind `json:"kind,omitempty"` Type TypeRef `json:"type"` Args []Field `json:"args,omitempty"` DefaultValue interface{} `json:"defaultValue,omitempty"` }
Field is an attribute of a schema Type object.
func (*Field) GetDescription ¶
GetDescription formats the description into a GoDoc comment.
func (*Field) GetTypeNameWithOverride ¶
func (f *Field) GetTypeNameWithOverride(pkgConfig *config.PackageConfig) (string, error)
GetTypeNameWithOverride returns the typeName, taking into consideration any FieldTypeOverride specified in the PackageConfig.
type MutationInfo ¶
type MutationInfo struct {
Name string `yaml:"name"`
}
type QueryResponse ¶
type QueryResponse struct { Data struct { Type Type `json:"__type"` Schema Schema `json:"__schema"` } `json:"data"` }
func ParseResponse ¶
func ParseResponse(resp *http.Response) (*QueryResponse, error)
type QueryTypeVars ¶
type QueryTypeVars struct {
Name string `json:"typeName"`
}
Helper function to make queries, lives here with the constant query
type Schema ¶
type Schema struct { MutationType *Type `json:"mutationType,omitempty"` QueryType *Type `json:"queryType,omitempty"` SubscriptionType *Type `json:"subscriptionType,omitempty"` Types []*Type `json:"types,omitempty"` }
Schema contains data about the GraphQL schema as returned by the server
func (*Schema) LookupTypeByName ¶
LookupTypeByName digs in the schema for a type that matches the given name.
type SubscriptionInfo ¶
type SubscriptionInfo struct {
Name string `yaml:"name"`
}
type Type ¶
type Type struct { Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Kind Kind `json:"kind,omitempty"` EnumValues []EnumValue `json:"enumValues,omitempty"` Fields []Field `json:"fields,omitempty"` InputFields []Field `json:"inputFields,omitempty"` Interfaces []TypeRef `json:"interfaces,omitempty"` PossibleTypes []TypeRef `json:"possibleTypes,omitempty"` }
Type defines a specific type within the schema
func (*Type) GetDescription ¶
GetDescription formats the description into a GoDoc comment.
type TypeRef ¶
type TypeRef struct { Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Kind Kind `json:"kind,omitempty"` OfType *TypeRef `json:"ofType,omitempty"` }
TypeRef is a GraphQL reference to a Type.
func (*TypeRef) GetDescription ¶
GetDescription looks for anything in the description before \n\n---\n and filters off anything after that (internal messaging that is not useful here)
func (*TypeRef) GetType ¶
GetType resolves the given SchemaInputField into a field name to use on a go struct.
type, recurse, error
func (*TypeRef) GetTypeName ¶
GetTypeName returns the name of the current type, or performs a recursive lookup to determine the name of the nested OfType object's name. In the case that neither are matched, the string "UNKNOWN" is returned. In the GraphQL schema, a non-empty name seems to appear only once in a TypeRef tree, so we want to find the first non-empty.