Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Handler ¶
func Handler(schema Schema) http.HandlerFunc
Handler creates an HTTP handler for GraphQL requests Works with both net/http and Gin (via gin.WrapH)
func PlaygroundHandler ¶
func PlaygroundHandler(endpoint string) http.HandlerFunc
PlaygroundHandler creates an HTTP handler that serves a GraphQL playground Uses Apollo Sandbox by default (most modern and stable)
func PlaygroundHandlerWithType ¶
func PlaygroundHandlerWithType(endpoint string, playgroundType PlaygroundType) http.HandlerFunc
PlaygroundHandlerWithType creates a playground handler with a specific type
Types ¶
type PlaygroundType ¶
type PlaygroundType string
PlaygroundType determines which playground interface to use
const ( PlaygroundTypeApolloSandbox PlaygroundType = "apollo" // Apollo Sandbox (recommended) PlaygroundTypeGraphiQL PlaygroundType = "graphiql" // GraphiQL (stable) PlaygroundTypePlayground PlaygroundType = "playground" // GraphQL Playground (legacy) )
type Request ¶
type Request struct {
Query string `json:"query"`
Variables map[string]interface{} `json:"variables"`
OperationName string `json:"operationName"`
}
Request represents a GraphQL HTTP request
type Schema ¶
type Schema interface {
Execute(ctx context.Context, query string, variables map[string]interface{}, operationName string) *types.Result
GetContextBuilder() func(r *http.Request) context.Context
}
Schema is the interface that the handler needs This avoids importing rocket package to prevent cycles
Click to show internal directories.
Click to hide internal directories.