Documentation
¶
Index ¶
- Variables
- func FieldResolverCost(n int) func(FieldCostContext) FieldCost
- func IsSubscription(doc *ast.Document, operationName string) bool
- type Directive
- type DirectiveDefinition
- type EnumType
- type EnumValueDefinition
- type Error
- type ExtendedError
- type FeatureSet
- type FieldContext
- type FieldCost
- type FieldCostContext
- type FieldDefinition
- type InputObjectType
- type InputValueDefinition
- type InterfaceType
- type ListType
- type Location
- type NamedType
- type NonNullType
- type ObjectType
- type Request
- type ResolvePromise
- type ResolveResult
- type Response
- type ScalarType
- type Schema
- type SchemaDefinition
- type Type
- type UnionType
- type ValidatorRule
Constants ¶
This section is empty.
Variables ¶
var BooleanType = schema.BooleanType
BooleanType implements the Boolean type as defined by the GraphQL spec.
var FloatType = schema.FloatType
FloatType implements the Float type as defined by the GraphQL spec.
var IDType = schema.IDType
IDType implements the ID type as defined by the GraphQL spec. It can be deserialized from a string or an integer type, but always serializes to a string.
var IncludeDirective = schema.IncludeDirective
IncludeDirective implements the @include directive as defined by the GraphQL spec.
var IntType = schema.IntType
IntType implements the Int type as defined by the GraphQL spec.
var SkipDirective = schema.SkipDirective
SkipDirective implements the @skip directive as defined by the GraphQL spec.
var StringType = schema.StringType
StringType implements the String type as defined by the GraphQL spec.
Functions ¶
func FieldResolverCost ¶
func FieldResolverCost(n int) func(FieldCostContext) FieldCost
Returns a cost function which returns a constant resolver cost with no multiplier.
func IsSubscription ¶
IsSubscription returns true if the operation with the given name is a subscription operation. operationName can be "", in which case true will be returned if the only operation in the document is a subscription. In any error case (such as multiple matching subscriptions), false is returned.
Types ¶
type DirectiveDefinition ¶
type DirectiveDefinition = schema.DirectiveDefinition
DirectiveDefinition defines a directive.
type EnumValueDefinition ¶
type EnumValueDefinition = schema.EnumValueDefinition
EnumValueDefinition defines a possible value for an enum type.
type Error ¶
type Error struct { Message string `json:"message"` Locations []Location `json:"locations,omitempty"` Path []interface{} `json:"path,omitempty"` // To populate this field, your resolvers can return errors that implement ExtendedError. Extensions map[string]interface{} `json:"extensions,omitempty"` }
Error represents a GraphQL error as defined by the spec.
func ParseAndValidate ¶
func ParseAndValidate(query string, schema *Schema, features schema.FeatureSet, additionalRules ...ValidatorRule) (*ast.Document, []*Error)
ParseAndValidate parses and validates a query.
type ExtendedError ¶
ExtendedError can be used to add data to a GraphQL error. If a resolver returns an error that implements this interface, the error's extensions property will be populated.
type FeatureSet ¶
type FeatureSet = schema.FeatureSet
FeatureSet represents a set of features.
func NewFeatureSet ¶
func NewFeatureSet(features ...string) FeatureSet
NewFeatureSet creates a new feature set with the given features.
type FieldContext ¶
type FieldContext = schema.FieldContext
FieldContext is provided to field resolvers and contains important context such as the current object and arguments.
type FieldCost ¶
FieldCost describes the cost of resolving a field, enabling rate limiting and metering.
type FieldCostContext ¶
type FieldCostContext = schema.FieldCostContext
FieldCostContext contains important context passed to field cost functions.
type FieldDefinition ¶
type FieldDefinition = schema.FieldDefinition
FieldDefinition defines a field on an object type.
type InputObjectType ¶
type InputObjectType = schema.InputObjectType
InputObjectType represents a GraphQL input object type.
type InputValueDefinition ¶
type InputValueDefinition = schema.InputValueDefinition
InputValueDefinition defines an input value such as an argument.
type InterfaceType ¶
type InterfaceType = schema.InterfaceType
InterfaceType represents a GraphQL interface type.
type ListType ¶
ListType represents a GraphQL list type.
func NewListType ¶
NewListType creates a new list type with the given element type.
type NonNullType ¶
type NonNullType = schema.NonNullType
NonNullType represents a non-null GraphQL type.
func NewNonNullType ¶
func NewNonNullType(t Type) *NonNullType
NewNonNullType creates a new non-null type with the given wrapped type.
type Request ¶
type Request struct { Context context.Context Query string // In some cases, you may want to optimize by providing the parsed and validated AST document // instead of Query. Document *ast.Document Schema *Schema OperationName string VariableValues map[string]interface{} Features FeatureSet Extensions map[string]interface{} InitialValue interface{} IdleHandler func() }
Request defines all of the inputs required to execute a GraphQL query.
func NewRequestFromHTTP ¶
NewRequestFromHTTP constructs a Request from an HTTP request. Requests may be GET requests using query string parameters or POST requests with either the application/json or application/graphql content type. If the request is malformed, an HTTP error code and error are returned.
func (*Request) ValidateCost ¶
Calculates the cost of the requested operation and ensures it is not greater than max. If max is -1, no limit is enforced. If actual is non-nil, it is set to the actual cost of the operation. Queries with costs that are too high to calculate due to overflows always result in an error when max is non-negative, and actual will be set to the maximum possible value.
type ResolvePromise ¶
type ResolvePromise = executor.ResolvePromise
ResolvePromise can be used to resolve fields asynchronously. You may return ResolvePromise from the field's resolve function. If you do, you must define an IdleHandler for the request. Any time request execution is unable to proceed, the idle handler will be invoked. Before the idle handler returns, a result must be sent to at least one previously returned ResolvePromise.
type ResolveResult ¶
type ResolveResult = executor.ResolveResult
ResolveResult represents the result of a field resolver. This type is generally used with ResolvePromise to pass around asynchronous results.
type Response ¶
type Response struct { Data *interface{} `json:"data,omitempty"` Errors []*Error `json:"errors,omitempty"` }
Response represents the result of executing a GraphQL query.
type Schema ¶
Schema represents a GraphQL schema.
func NewSchema ¶
func NewSchema(def *SchemaDefinition) (*Schema, error)
NewSchema validates a schema definition and builds a Schema from it.
type SchemaDefinition ¶
type SchemaDefinition = schema.SchemaDefinition
SchemaDefinition defines a GraphQL schema.
type ValidatorRule ¶
ValidatorRule defines a rule that the validator will evaluate.
func ValidateCost ¶
func ValidateCost(operationName string, variableValues map[string]interface{}, max int, actual *int, defaultCost schema.FieldCost) ValidatorRule
Calculates the cost of the given operation and ensures it is not greater than max. If max is -1, no limit is enforced. If actual is non-nil, it is set to the actual cost of the operation. Queries with costs that are too high to calculate due to overflows always result in an error when max is non-negative, and actual will be set to the maximum possible value.