Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ type ResultCallbackFn func(ctx context.Context, params *graphql.Params, result *

type Handler struct {
Schema *graphql.Schema
pretty bool
formatErrorFn func(err error) gqlerrors.FormattedError
graphiql bool
playground bool
rootObjectFn RootObjectFn
pretty bool
resultCallbackFn ResultCallbackFn
formatErrorFn func(err error) gqlerrors.FormattedError
rootObjectFn RootObjectFn
tracer graphql.Tracer
}

type RequestOptions struct {
Expand Down Expand Up @@ -130,11 +131,12 @@ func (h *Handler) ContextHandler(ctx context.Context, w http.ResponseWriter, r *

// execute graphql query
params := graphql.Params{
Schema: *h.Schema,
Context: ctx,
OperationName: opts.OperationName,
RequestString: opts.Query,
Schema: *h.Schema,
Tracer: h.tracer,
VariableValues: opts.Variables,
OperationName: opts.OperationName,
Context: ctx,
}
if h.rootObjectFn != nil {
params.RootObject = h.rootObjectFn(ctx, r)
Expand Down Expand Up @@ -197,13 +199,14 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
type RootObjectFn func(ctx context.Context, r *http.Request) map[string]interface{}

type Config struct {
Schema *graphql.Schema
Pretty bool
FormatErrorFn func(err error) gqlerrors.FormattedError
GraphiQL bool
Playground bool
RootObjectFn RootObjectFn
Pretty bool
ResultCallbackFn ResultCallbackFn
FormatErrorFn func(err error) gqlerrors.FormattedError
RootObjectFn RootObjectFn
Schema *graphql.Schema
Tracer graphql.Tracer
}

func NewConfig() *Config {
Expand All @@ -226,11 +229,12 @@ func New(p *Config) *Handler {

return &Handler{
Schema: p.Schema,
pretty: p.Pretty,
formatErrorFn: p.FormatErrorFn,
graphiql: p.GraphiQL,
playground: p.Playground,
rootObjectFn: p.RootObjectFn,
pretty: p.Pretty,
resultCallbackFn: p.ResultCallbackFn,
formatErrorFn: p.FormatErrorFn,
rootObjectFn: p.RootObjectFn,
tracer: p.Tracer,
}
}