Documentation
¶
Index ¶
- Constants
- type ContextFunc
- type FormatErrorFunc
- type GraphQLTransportWS
- type GraphQLWS
- type Option
- func WithContextFunc(f ContextFunc) Option
- func WithFormatErrorFunc(f FormatErrorFunc) Option
- func WithGraphQLTransportWS(o *GraphQLTransportWS) Option
- func WithGraphQLWS(o *GraphQLWS) Option
- func WithGraphiQLOptions(o *ide.GraphiQLOptions) Option
- func WithLogFunc(l logger.LogFunc) Option
- func WithPlaygroundOptions(o *ide.PlaygroundOptions) Option
- func WithPretty() Option
- func WithResultCallbackFunc(f ResultCallbackFunc) Option
- func WithRootValueFunc(f RootValueFunc) Option
- type Options
- type RequestOptions
- type RequestType
- type ResultCallbackFunc
- type RootValueFunc
- type Server
Constants ¶
View Source
const ( ContentTypeJSON = "application/json" ContentTypeGraphQL = "application/graphql" ContentTypeFormURLEncoded = "application/x-www-form-urlencoded" )
Constants
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FormatErrorFunc ¶
type FormatErrorFunc func(err error) gqlerrors.FormattedError
type GraphQLTransportWS ¶ added in v0.3.0
type GraphQLTransportWS struct {
ConnectionInitWaitTimeout time.Duration
RootValueFunc func(ctx context.Context, r *http.Request, op *ast.OperationDefinition) map[string]interface{}
ContextValueFunc func(c protocol.Context, msg protocol.OperationMessage, execArgs graphql.Params) (context.Context, gqlerrors.FormattedErrors)
OnConnect func(c protocol.Context) (interface{}, error)
OnPing func(c protocol.Context, payload map[string]interface{})
OnPong func(c protocol.Context, payload map[string]interface{})
OnDisconnect func(c protocol.Context, code graphqltransportws.CloseCode, reason string)
OnClose func(c protocol.Context, code graphqltransportws.CloseCode, reason string)
OnSubscribe func(c protocol.Context, msg graphqltransportws.SubscribeMessage) (*graphql.Params, gqlerrors.FormattedErrors)
OnNext func(c protocol.Context, msg graphqltransportws.NextMessage, args graphql.Params, Result *graphql.Result) (*protocol.ExecutionResult, error)
OnError func(c protocol.Context, msg graphqltransportws.ErrorMessage, errs gqlerrors.FormattedErrors) (gqlerrors.FormattedErrors, error)
OnComplete func(c protocol.Context, msg graphqltransportws.CompleteMessage) error
OnOperation func(c protocol.Context, msg graphqltransportws.SubscribeMessage, args graphql.Params, result interface{}) (interface{}, error)
}
type GraphQLWS ¶ added in v0.3.0
type GraphQLWS struct {
ConnectionInitWaitTimeout time.Duration
KeepAlive time.Duration
RootValueFunc func(ctx context.Context, r *http.Request, op *ast.OperationDefinition) map[string]interface{}
ContextValueFunc func(c protocol.Context, msg protocol.OperationMessage, execArgs graphql.Params) (context.Context, gqlerrors.FormattedErrors)
OnConnect func(c protocol.Context, payload interface{}) (interface{}, error)
OnDisconnect func(c protocol.Context)
OnOperation func(c protocol.Context, msg graphqlws.StartMessage, params *graphql.Params) (*graphql.Params, error)
OnOperationComplete func(c protocol.Context, id string)
}
type Option ¶
type Option func(opts *Options)
func WithContextFunc ¶
func WithContextFunc(f ContextFunc) Option
func WithFormatErrorFunc ¶
func WithFormatErrorFunc(f FormatErrorFunc) Option
func WithGraphQLTransportWS ¶ added in v0.3.0
func WithGraphQLTransportWS(o *GraphQLTransportWS) Option
func WithGraphQLWS ¶ added in v0.3.0
func WithGraphiQLOptions ¶
func WithGraphiQLOptions(o *ide.GraphiQLOptions) Option
func WithLogFunc ¶ added in v0.3.0
func WithPlaygroundOptions ¶
func WithPlaygroundOptions(o *ide.PlaygroundOptions) Option
func WithPretty ¶
func WithPretty() Option
func WithResultCallbackFunc ¶
func WithResultCallbackFunc(f ResultCallbackFunc) Option
func WithRootValueFunc ¶
func WithRootValueFunc(f RootValueFunc) Option
type Options ¶ added in v0.3.0
type Options struct {
// common configs
Pretty bool
LogFunc logger.LogFunc
RootValueFunc RootValueFunc
ContextFunc ContextFunc
FormatErrorFunc FormatErrorFunc
ResultCallbackFunc ResultCallbackFunc
// WebSocket configs
GraphQLWS *GraphQLWS
GraphQLTransportWS *GraphQLTransportWS
// IDE configs
Playground *ide.PlaygroundOptions
GraphiQL *ide.GraphiQLOptions
}
func NewOptions ¶ added in v0.3.0
NewOptions creates a new default options with optional options funcs
type RequestOptions ¶
type RequestOptions struct {
Query string `json:"query" url:"query" schema:"query"`
Variables map[string]interface{} `json:"variables" url:"variables" schema:"variables"`
OperationName string `json:"operationName" url:"operationName" schema:"operationName"`
}
RequestOptions options
func GetRequestOptions ¶
func GetRequestOptions(r *http.Request) *RequestOptions
GetRequestOptions Parses a http.Request into GraphQL request options struct without clearning the body
func NewRequestOptions ¶
func NewRequestOptions(r *http.Request) *RequestOptions
NewRequestOptions Parses a http.Request into GraphQL request options struct
type RequestType ¶ added in v0.3.0
type RequestType string
type ResultCallbackFunc ¶
type RootValueFunc ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) ContextHandler ¶
ContextHandler provides an entrypoint into executing graphQL queries with a user-provided context.
Click to show internal directories.
Click to hide internal directories.