http

package
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 6 Imported by: 0

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL