Documentation ¶
Overview ¶
Package server provides serving GraphQL over HTTP
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GraphQLHandler ¶
type GraphQLHandler struct {
// contains filtered or unexported fields
}
A GraphQLHandler is a http.Handler that fulfills GraphQL requests
func NewGraphQLHandler ¶
func NewGraphQLHandler(s *schema.Schema, config *GraphQLHandlerConfig) *GraphQLHandler
NewGraphQLHandler creates a new GraphQLHandler with the specified configuration
func (*GraphQLHandler) ServeHTTP ¶
func (h *GraphQLHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)
type GraphQLHandlerConfig ¶
type GraphQLHandlerConfig struct { // Callback to build queries. Can be used to implement query caching or additional validation. QueryBuilder QueryBuilder // Callback to execute queries. Can be used to inject request specific items (loggers, listeners, context variables, etc), // as well as for logging QueryExecutor QueryExecutor // Callback to wrap execution of queries. Can be used to inject request specific items (loggers, listeners, context variables, etc), // as well as for logging QueryExecutionWrapper QueryExecutionWrapper // Root object to use. RootObject interface{} // Provider for root objects RootObjectProvider RootObjectProvider // By default GraphiQL is enabled. This can be used to disable it. DisableGraphiQL bool // Max size of request body. If -1, no limit. Server will respond with 413 // if the size is exceeded MaxRequestBodySize int64 }
A GraphQLHandlerConfig supplies configuration parameters to NewGraphQLHandler
type QueryBuilder ¶
type QueryBuilder func(schema *schema.Schema, text string, operationName string) (*query.PreparedQuery, error)
A QueryBuilder is used to transform a query text and operation name into a PreparedQuery.
The default implementation recompiles the query each request, a production configuration should use some sort of cache to reuse previously compiled queries
var DefaultQueryBuilder QueryBuilder = func(schema *schema.Schema, text string, operationName string) (*query.PreparedQuery, error) { return query.PrepareQuery(text, operationName, schema) }
DefaultQueryBuilder is a simple QueryBuilder that recompiles the query each request.
type QueryExecutionWrapper ¶
type QueryExecutionWrapper func(queryInfo QueryInfo, req *http.Request, responseHeaders http.Header, proceed func(context.Context, query.ExecutionListener))
A QueryExecutionWrapper wraps execution of a query or batch of queries. Implementations of this may add variables to the context, set up callbacks, and set up tracing.
type QueryExecutor ¶
type QueryExecutor func(q *query.PreparedQuery, req *http.Request, vars query.Variables, responseHeaders http.Header) []byte
A QueryExecutor runs a prepared query. Implementations of this may add variables to the context, set up callbacks, and set up tracing. This method is deprecated, use a QueryExecutionWrapper instead
type QueryInfo ¶
type QueryInfo interface { GetNQueries() int GetQuery(n int) *query.PreparedQuery GetVariables(n int) query.Variables GetRootObject(n int) interface{} }
QueryInfo supplies information about the queries being executed to a QueryExecutionWrapper
type RootObjectProvider ¶
A RootObjectProvider is used to create root objects for queries