graphql

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContext

func FromContext(ctx context.Context) (*gin.Context, bool)

FromContext extracts the *gin.Context from a resolver's context.Context. Returns the gin.Context and true if found, or nil and false otherwise.

func Handler

func Handler(schema gql.Schema) gin.HandlerFunc

Handler returns a gin.HandlerFunc that executes GraphQL queries against the given schema. Supports POST (JSON body) and GET (query parameters).

POST body format:

{"query": "...", "variables": {...}, "operationName": "..."}

GET query parameters: ?query=...&variables={...}&operationName=...

Responses follow the GraphQL over HTTP specification:

{"data": ..., "errors": [...]}

func Playground

func Playground(title, endpoint string) gin.HandlerFunc

Playground returns a gin.HandlerFunc that serves the GraphiQL IDE. title appears in the browser tab; endpoint is the URL of the GraphQL handler (e.g., "/graphql").

Types

type Request

type Request struct {
	Query         string                 `json:"query"`
	Variables     map[string]interface{} `json:"variables"`
	OperationName string                 `json:"operationName"`
}

Request represents a GraphQL query received from the client.

Jump to

Keyboard shortcuts

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