gqlgen: Index | Files | Directories

package graphql

import ""


Package Files

any.go bool.go context.go error.go exec.go fieldset.go float.go id.go int.go jsonw.go map.go oneshot.go recovery.go response.go root.go string.go time.go tracer.go upload.go version.go


const Version = "v0.9.3-dev"


var False = &lit{falseLit}
var Null = &lit{nullLit}
var True = &lit{trueLit}

func AddError Uses

func AddError(ctx context.Context, err error)

AddError is a convenience method for adding an error to the current response

func AddErrorf Uses

func AddErrorf(ctx context.Context, format string, args ...interface{})

AddErrorf is a convenience method for adding an error to the current response

func CollectAllFields Uses

func CollectAllFields(ctx context.Context) []string

CollectAllFields returns a slice of all GraphQL field names that were selected for the current resolver context. The slice will contain the unique set of all field names requested regardless of fragment type conditions.

func DefaultDirectiveMiddleware Uses

func DefaultDirectiveMiddleware(ctx context.Context, next Resolver) (res interface{}, err error)

func DefaultErrorPresenter Uses

func DefaultErrorPresenter(ctx context.Context, err error) *gqlerror.Error

func DefaultRecover Uses

func DefaultRecover(ctx context.Context, err interface{}) error

func DefaultRequestMiddleware Uses

func DefaultRequestMiddleware(ctx context.Context, next func(ctx context.Context) []byte) []byte

func DefaultResolverMiddleware Uses

func DefaultResolverMiddleware(ctx context.Context, next Resolver) (res interface{}, err error)

func OneShot Uses

func OneShot(resp *Response) func() *Response

func UnmarshalAny Uses

func UnmarshalAny(v interface{}) (interface{}, error)

func UnmarshalBoolean Uses

func UnmarshalBoolean(v interface{}) (bool, error)

func UnmarshalFloat Uses

func UnmarshalFloat(v interface{}) (float64, error)

func UnmarshalID Uses

func UnmarshalID(v interface{}) (string, error)

func UnmarshalInt Uses

func UnmarshalInt(v interface{}) (int, error)

func UnmarshalInt32 Uses

func UnmarshalInt32(v interface{}) (int32, error)

func UnmarshalInt64 Uses

func UnmarshalInt64(v interface{}) (int64, error)

func UnmarshalIntID Uses

func UnmarshalIntID(v interface{}) (int, error)

func UnmarshalMap Uses

func UnmarshalMap(v interface{}) (map[string]interface{}, error)

func UnmarshalString Uses

func UnmarshalString(v interface{}) (string, error)

func UnmarshalTime Uses

func UnmarshalTime(v interface{}) (time.Time, error)

func WithRequestContext Uses

func WithRequestContext(ctx context.Context, rc *RequestContext) context.Context

func WithResolverContext Uses

func WithResolverContext(ctx context.Context, rc *ResolverContext) context.Context

type Array Uses

type Array []Marshaler

func (Array) MarshalGQL Uses

func (a Array) MarshalGQL(writer io.Writer)

type CollectedField Uses

type CollectedField struct {

    Selections ast.SelectionSet

func CollectFields Uses

func CollectFields(reqCtx *RequestContext, selSet ast.SelectionSet, satisfies []string) []CollectedField

CollectFields returns the set of fields from an ast.SelectionSet where all collected fields satisfy at least one of the GraphQL types passed through satisfies. Providing an empty or nil slice for satisfies will return collect all fields regardless of fragment type conditions.

func CollectFieldsCtx Uses

func CollectFieldsCtx(ctx context.Context, satisfies []string) []CollectedField

This is just a convenient wrapper method for CollectFields

type ComplexityLimitFunc Uses

type ComplexityLimitFunc func(ctx context.Context) int

type ErrorPresenterFunc Uses

type ErrorPresenterFunc func(context.Context, error) *gqlerror.Error

type ExecutableSchema Uses

type ExecutableSchema interface {
    Schema() *ast.Schema

    Complexity(typeName, fieldName string, childComplexity int, args map[string]interface{}) (int, bool)
    Query(ctx context.Context, op *ast.OperationDefinition) *Response
    Mutation(ctx context.Context, op *ast.OperationDefinition) *Response
    Subscription(ctx context.Context, op *ast.OperationDefinition) func() *Response

type ExtendedError Uses

type ExtendedError interface {
    Extensions() map[string]interface{}

type FieldMiddleware Uses

type FieldMiddleware func(ctx context.Context, next Resolver) (res interface{}, err error)

func ChainFieldMiddleware Uses

func ChainFieldMiddleware(handleFunc ...FieldMiddleware) FieldMiddleware

ChainFieldMiddleware add chain by FieldMiddleware

type FieldSet Uses

type FieldSet struct {
    Values []Marshaler
    // contains filtered or unexported fields

func NewFieldSet Uses

func NewFieldSet(fields []CollectedField) *FieldSet

func (*FieldSet) Concurrently Uses

func (m *FieldSet) Concurrently(i int, f func() Marshaler)

func (*FieldSet) Dispatch Uses

func (m *FieldSet) Dispatch()

func (*FieldSet) MarshalGQL Uses

func (m *FieldSet) MarshalGQL(writer io.Writer)

type Marshaler Uses

type Marshaler interface {
    MarshalGQL(w io.Writer)

func MarshalAny Uses

func MarshalAny(v interface{}) Marshaler

func MarshalBoolean Uses

func MarshalBoolean(b bool) Marshaler

func MarshalFloat Uses

func MarshalFloat(f float64) Marshaler

func MarshalID Uses

func MarshalID(s string) Marshaler

func MarshalInt Uses

func MarshalInt(i int) Marshaler

func MarshalInt32 Uses

func MarshalInt32(i int32) Marshaler

func MarshalInt64 Uses

func MarshalInt64(i int64) Marshaler

func MarshalIntID Uses

func MarshalIntID(i int) Marshaler

func MarshalMap Uses

func MarshalMap(val map[string]interface{}) Marshaler

func MarshalString Uses

func MarshalString(s string) Marshaler

func MarshalTime Uses

func MarshalTime(t time.Time) Marshaler

func MarshalUpload Uses

func MarshalUpload(f Upload) Marshaler

type Mutation Uses

type Mutation struct{}

type NopTracer Uses

type NopTracer struct{}

func (NopTracer) EndFieldExecution Uses

func (NopTracer) EndFieldExecution(ctx context.Context)

func (NopTracer) EndOperationExecution Uses

func (NopTracer) EndOperationExecution(ctx context.Context)

func (NopTracer) EndOperationParsing Uses

func (NopTracer) EndOperationParsing(ctx context.Context)

func (NopTracer) EndOperationValidation Uses

func (NopTracer) EndOperationValidation(ctx context.Context)

func (NopTracer) StartFieldChildExecution Uses

func (NopTracer) StartFieldChildExecution(ctx context.Context) context.Context

func (NopTracer) StartFieldExecution Uses

func (NopTracer) StartFieldExecution(ctx context.Context, field CollectedField) context.Context

func (NopTracer) StartFieldResolverExecution Uses

func (NopTracer) StartFieldResolverExecution(ctx context.Context, rc *ResolverContext) context.Context

func (NopTracer) StartOperationExecution Uses

func (NopTracer) StartOperationExecution(ctx context.Context) context.Context

func (NopTracer) StartOperationParsing Uses

func (NopTracer) StartOperationParsing(ctx context.Context) context.Context

func (NopTracer) StartOperationValidation Uses

func (NopTracer) StartOperationValidation(ctx context.Context) context.Context

type Query Uses

type Query struct{}

type RecoverFunc Uses

type RecoverFunc func(ctx context.Context, err interface{}) (userMessage error)

type RequestContext Uses

type RequestContext struct {
    RawQuery  string
    Variables map[string]interface{}
    Doc       *ast.QueryDocument

    ComplexityLimit      int
    OperationComplexity  int
    DisableIntrospection bool

    // ErrorPresenter will be used to generate the error
    // message from errors given to Error().
    ErrorPresenter      ErrorPresenterFunc
    Recover             RecoverFunc
    ResolverMiddleware  FieldMiddleware
    DirectiveMiddleware FieldMiddleware
    RequestMiddleware   RequestMiddleware
    Tracer              Tracer

    Errors gqlerror.List

    Extensions map[string]interface{}
    // contains filtered or unexported fields

func GetRequestContext Uses

func GetRequestContext(ctx context.Context) *RequestContext

func NewRequestContext Uses

func NewRequestContext(doc *ast.QueryDocument, query string, variables map[string]interface{}) *RequestContext

func (*RequestContext) Error Uses

func (c *RequestContext) Error(ctx context.Context, err error)

Error sends an error to the client, passing it through the formatter.

func (*RequestContext) Errorf Uses

func (c *RequestContext) Errorf(ctx context.Context, format string, args ...interface{})

Errorf sends an error string to the client, passing it through the formatter.

func (*RequestContext) GetErrors Uses

func (c *RequestContext) GetErrors(rctx *ResolverContext) gqlerror.List

GetErrors returns a list of errors that occurred in the current field

func (*RequestContext) HasError Uses

func (c *RequestContext) HasError(rctx *ResolverContext) bool

HasError returns true if the current field has already errored

func (*RequestContext) RegisterExtension Uses

func (c *RequestContext) RegisterExtension(key string, value interface{}) error

RegisterExtension registers an extension, returns error if extension has already been registered

type RequestMiddleware Uses

type RequestMiddleware func(ctx context.Context, next func(ctx context.Context) []byte) []byte

type Resolver Uses

type Resolver func(ctx context.Context) (res interface{}, err error)

type ResolverContext Uses

type ResolverContext struct {
    Parent *ResolverContext
    // The name of the type this field belongs to
    Object string
    // These are the args after processing, they can be mutated in middleware to change what the resolver will get.
    Args map[string]interface{}
    // The raw field
    Field CollectedField
    // The index of array in path.
    Index *int
    // The result object of resolver
    Result interface{}
    // IsMethod indicates if the resolver is a method
    IsMethod bool

func GetResolverContext Uses

func GetResolverContext(ctx context.Context) *ResolverContext

func (*ResolverContext) Path Uses

func (r *ResolverContext) Path() []interface{}

type Response Uses

type Response struct {
    Errors     gqlerror.List          `json:"errors,omitempty"`
    Data       json.RawMessage        `json:"data"`
    Extensions map[string]interface{} `json:"extensions,omitempty"`

Errors are intentionally serialized first based on the advice in and

func ErrorResponse Uses

func ErrorResponse(ctx context.Context, messagef string, args ...interface{}) *Response

type Subscription Uses

type Subscription struct{}

type Tracer Uses

type Tracer interface {
    StartOperationParsing(ctx context.Context) context.Context
    EndOperationParsing(ctx context.Context)
    StartOperationValidation(ctx context.Context) context.Context
    EndOperationValidation(ctx context.Context)
    StartOperationExecution(ctx context.Context) context.Context
    StartFieldExecution(ctx context.Context, field CollectedField) context.Context
    StartFieldResolverExecution(ctx context.Context, rc *ResolverContext) context.Context
    StartFieldChildExecution(ctx context.Context) context.Context
    EndFieldExecution(ctx context.Context)
    EndOperationExecution(ctx context.Context)

type Unmarshaler Uses

type Unmarshaler interface {
    UnmarshalGQL(v interface{}) error

type Upload Uses

type Upload struct {
    File     io.Reader
    Filename string
    Size     int64

func UnmarshalUpload Uses

func UnmarshalUpload(v interface{}) (Upload, error)

type WriterFunc Uses

type WriterFunc func(writer io.Writer)

func (WriterFunc) MarshalGQL Uses

func (f WriterFunc) MarshalGQL(w io.Writer)


introspectionintrospection implements the spec defined in

Package graphql imports 13 packages (graph) and is imported by 100 packages. Updated 2019-08-16. Refresh now. Tools for package owners.