Documentation
¶
Overview ¶
Generates a GraphQL API handler for your convenience
Index ¶
Constants ¶
View Source
const MainContextKey = "mainContext"
MainContextKey is used to provide a structured context object to all GraphQL resolvers
Variables ¶
This section is empty.
Functions ¶
func GenerateGraphQLAPIHandler ¶
func GenerateGraphQLAPIHandler(schema *graphql.Schema, config *HandlerConfig, contextObj interface{}) http.HandlerFunc
GenerateGraphQLAPIHandler generates a HTTP handler func that prepares and processes requests to the GraphQL API in an automated fashion
Types ¶
type HTTPHandlerFuncWithError ¶
type HTTPHandlerFuncWithError func(w http.ResponseWriter, r *http.Request) error
HTTPHandlerFuncWithError is the type used for middlewares
type HandlerConfig ¶
type HandlerConfig struct {
// Runs before any processing is done for requests
OnRequest HTTPHandlerFuncWithError
// Runs before processing the GraphQL query but after
// doing some initial processing
PreProcess HTTPHandlerFuncWithError
// Runs right after the GraphQL query has been processed
// and before the result is checked for errors
PostProcess HTTPHandlerFuncWithError
// Runs after checking for errors in the GraphQL query result
// and before writing the result to the client. Only runs if
// no errors were encountered.
PreWriteResult HTTPHandlerFuncWithError
// Runs after writing the result to the client. This is the last
// of all handlers that is run.
PostWriteResult HTTPHandlerFuncWithError
// Specifying `true` will disallow using the URL query parameter
// as a means of transporting the GraphQL query
DisableURLQuery bool
// Specifying `true` will disallow using the POST body
// as a means of transporting the GraphQL query
DisableBodyQuery bool
}
HandlerConfig allows you to attach middlewares and configure the behavior as you like
Click to show internal directories.
Click to hide internal directories.