Documentation ¶
Index ¶
- Constants
- Variables
- func AddError(ctx context.Context, err error)
- func AddErrorf(ctx context.Context, format string, args ...interface{})
- func CollectAllFields(ctx context.Context) []string
- func DefaultDirectiveMiddleware(ctx context.Context, next Resolver) (res interface{}, err error)
- func DefaultErrorPresenter(ctx context.Context, err error) *gqlerror.Error
- func DefaultRecover(ctx context.Context, err interface{}) error
- func DefaultRequestMiddleware(ctx context.Context, next func(ctx context.Context) []byte) []byte
- func DefaultResolverMiddleware(ctx context.Context, next Resolver) (res interface{}, err error)
- func OneShot(resp *Response) func() *Response
- func UnmarshalBoolean(v interface{}) (bool, error)
- func UnmarshalFloat(v interface{}) (float64, error)
- func UnmarshalID(v interface{}) (string, error)
- func UnmarshalInt(v interface{}) (int, error)
- func UnmarshalInt32(v interface{}) (int32, error)
- func UnmarshalInt64(v interface{}) (int64, error)
- func UnmarshalIntID(v interface{}) (int, error)
- func UnmarshalMap(v interface{}) (map[string]interface{}, error)
- func UnmarshalString(v interface{}) (string, error)
- func UnmarshalTime(v interface{}) (time.Time, error)
- func WithRequestContext(ctx context.Context, rc *RequestContext) context.Context
- func WithResolverContext(ctx context.Context, rc *ResolverContext) context.Context
- type Array
- type CollectedField
- type ErrorPresenterFunc
- type ExecutableSchema
- type ExtendedError
- type FieldMiddleware
- type FieldSet
- type Marshaler
- func MarshalBoolean(b bool) Marshaler
- func MarshalFloat(f float64) Marshaler
- func MarshalID(s string) Marshaler
- func MarshalInt(i int) Marshaler
- func MarshalInt32(i int32) Marshaler
- func MarshalInt64(i int64) Marshaler
- func MarshalIntID(i int) Marshaler
- func MarshalMap(val map[string]interface{}) Marshaler
- func MarshalString(s string) Marshaler
- func MarshalTime(t time.Time) Marshaler
- type Mutation
- type NopTracer
- func (NopTracer) EndFieldExecution(ctx context.Context)
- func (NopTracer) EndOperationExecution(ctx context.Context)
- func (NopTracer) EndOperationParsing(ctx context.Context)
- func (NopTracer) EndOperationValidation(ctx context.Context)
- func (NopTracer) StartFieldChildExecution(ctx context.Context) context.Context
- func (NopTracer) StartFieldExecution(ctx context.Context, field CollectedField) context.Context
- func (NopTracer) StartFieldResolverExecution(ctx context.Context, rc *ResolverContext) context.Context
- func (NopTracer) StartOperationExecution(ctx context.Context) context.Context
- func (NopTracer) StartOperationParsing(ctx context.Context) context.Context
- func (NopTracer) StartOperationValidation(ctx context.Context) context.Context
- type Query
- type RecoverFunc
- type RequestContext
- func (c *RequestContext) Error(ctx context.Context, err error)
- func (c *RequestContext) Errorf(ctx context.Context, format string, args ...interface{})
- func (c *RequestContext) GetErrors(rctx *ResolverContext) gqlerror.List
- func (c *RequestContext) HasError(rctx *ResolverContext) bool
- func (c *RequestContext) RegisterExtension(key string, value interface{}) error
- type RequestMiddleware
- type Resolver
- type ResolverContext
- type Response
- type Subscription
- type Tracer
- type Unmarshaler
- type WriterFunc
Constants ¶
const Version = "dev"
Variables ¶
var False = &lit{falseLit}
var Null = &lit{nullLit}
var True = &lit{trueLit}
Functions ¶
func CollectAllFields ¶ added in v0.8.2
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 DefaultErrorPresenter ¶
func DefaultRecover ¶
func UnmarshalBoolean ¶
func UnmarshalFloat ¶
func UnmarshalID ¶
func UnmarshalInt ¶
func UnmarshalInt32 ¶ added in v0.8.2
func UnmarshalInt64 ¶ added in v0.8.2
func UnmarshalIntID ¶ added in v0.8.2
func UnmarshalMap ¶
func UnmarshalString ¶
func UnmarshalTime ¶
func WithRequestContext ¶
func WithRequestContext(ctx context.Context, rc *RequestContext) context.Context
func WithResolverContext ¶
func WithResolverContext(ctx context.Context, rc *ResolverContext) context.Context
Types ¶
type CollectedField ¶
type CollectedField struct { *ast.Field Selections ast.SelectionSet }
func CollectFields ¶
func CollectFields(ctx context.Context, 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 ¶
func CollectFieldsCtx(ctx context.Context, satisfies []string) []CollectedField
This is just a convenient wrapper method for CollectFields
type ExecutableSchema ¶
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 ¶
type ExtendedError interface {
Extensions() map[string]interface{}
}
type FieldMiddleware ¶
func ChainFieldMiddleware ¶ added in v0.8.2
func ChainFieldMiddleware(handleFunc ...FieldMiddleware) FieldMiddleware
ChainFieldMiddleware add chain by FieldMiddleware
type FieldSet ¶ added in v0.8.2
type FieldSet struct { Values []Marshaler // contains filtered or unexported fields }
func NewFieldSet ¶ added in v0.8.2
func NewFieldSet(fields []CollectedField) *FieldSet
func (*FieldSet) Concurrently ¶ added in v0.8.2
func (*FieldSet) MarshalGQL ¶ added in v0.8.2
type Marshaler ¶
func MarshalBoolean ¶
func MarshalFloat ¶
func MarshalInt ¶
func MarshalInt32 ¶ added in v0.8.2
func MarshalInt64 ¶ added in v0.8.2
func MarshalIntID ¶ added in v0.8.2
func MarshalMap ¶
func MarshalString ¶
func MarshalTime ¶
type NopTracer ¶ added in v0.7.0
type NopTracer struct{}
func (NopTracer) EndFieldExecution ¶ added in v0.7.0
func (NopTracer) EndOperationExecution ¶ added in v0.7.0
func (NopTracer) EndOperationParsing ¶ added in v0.7.0
func (NopTracer) EndOperationValidation ¶ added in v0.7.0
func (NopTracer) StartFieldChildExecution ¶ added in v0.7.0
func (NopTracer) StartFieldExecution ¶ added in v0.7.0
func (NopTracer) StartFieldResolverExecution ¶ added in v0.7.0
func (NopTracer) StartOperationExecution ¶ added in v0.7.0
func (NopTracer) StartOperationParsing ¶ added in v0.7.0
type RecoverFunc ¶
type RequestContext ¶
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 ¶
func GetRequestContext(ctx context.Context) *RequestContext
func NewRequestContext ¶
func NewRequestContext(doc *ast.QueryDocument, query string, variables map[string]interface{}) *RequestContext
func (*RequestContext) Error ¶
func (c *RequestContext) Error(ctx context.Context, err error)
Error sends an error to the client, passing it through the formatter.
func (*RequestContext) Errorf ¶
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 ¶ added in v0.7.0
func (c *RequestContext) GetErrors(rctx *ResolverContext) gqlerror.List
GetErrors returns a list of errors that occurred in the current field
func (*RequestContext) HasError ¶ added in v0.5.0
func (c *RequestContext) HasError(rctx *ResolverContext) bool
HasError returns true if the current field has already errored
func (*RequestContext) RegisterExtension ¶ added in v0.6.0
func (c *RequestContext) RegisterExtension(key string, value interface{}) error
RegisterExtension registers an extension, returns error if extension has already been registered
type RequestMiddleware ¶
type ResolverContext ¶
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{} }
func GetResolverContext ¶
func GetResolverContext(ctx context.Context) *ResolverContext
func (*ResolverContext) Path ¶
func (r *ResolverContext) Path() []interface{}
type Response ¶
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 https://github.com/facebook/graphql/commit/7b40390d48680b15cb93e02d46ac5eb249689876#diff-757cea6edf0288677a9eea4cfc801d87R107 and https://github.com/facebook/graphql/pull/384
type Subscription ¶ added in v0.8.2
type Subscription struct{}
type Tracer ¶ added in v0.7.0
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 ¶
type Unmarshaler interface {
UnmarshalGQL(v interface{}) error
}
type WriterFunc ¶
func (WriterFunc) MarshalGQL ¶
func (f WriterFunc) MarshalGQL(w io.Writer)
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
introspection implements the spec defined in https://github.com/facebook/graphql/blob/master/spec/Section%204%20--%20Introspection.md#schema-introspection
|
introspection implements the spec defined in https://github.com/facebook/graphql/blob/master/spec/Section%204%20--%20Introspection.md#schema-introspection |