graphql

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthDirective

func AuthDirective(ctx context.Context, next func(ctx context.Context) (interface{}, error)) (interface{}, error)

AuthDirective implements the @auth directive. It checks if a user is authenticated in the context.

func LoadSchema

func LoadSchema(dir string, resolver interface{}, opts ...graphql.SchemaOpt) (*graphql.Schema, error)

LoadSchema reads all .graphql files in a directory and parses them into a Schema.

func NewDataLoader

func NewDataLoader[K comparable, V any](batchFn dataloader.BatchFunc[K, V]) *dataloader.Loader[K, V]

NewDataLoader creates a new dataloader with default settings.

func PlaygroundHandler

func PlaygroundHandler(endpoint string) http.HandlerFunc

PlaygroundHandler returns an http.Handler that renders the GraphiQL playground.

Types

type BatchResult

type BatchResult[V any] struct {
	Value V
	Error error
}

BatchResult is a helper to wrap values and errors for Dataloader.

type DateTime

type DateTime struct {
	time.Time
}

DateTime is a custom scalar for time.Time values in GraphQL.

func (DateTime) ImplementsGraphQLType

func (DateTime) ImplementsGraphQLType(name string) bool

ImplementsGraphQLType maps this Go type to the GraphQL scalar type.

func (DateTime) MarshalJSON

func (d DateTime) MarshalJSON() ([]byte, error)

MarshalJSON serializes a DateTime to JSON as an RFC3339 string.

func (*DateTime) UnmarshalGraphQL

func (d *DateTime) UnmarshalGraphQL(input any) error

UnmarshalGraphQL parses a DateTime from an input value.

type Directive

type Directive func(ctx context.Context, next func(ctx context.Context) (interface{}, error)) (interface{}, error)

Directive is a function that can wrap a resolver execution.

type Handler

type Handler struct {
	Schema *graphql.Schema
}

Handler implements http.Handler for executing GraphQL queries.

func NewHandler

func NewHandler(schema *graphql.Schema) *Handler

NewHandler creates a new GraphQL handler.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type JSON

type JSON struct {
	Value any
}

JSON is a custom scalar for arbitrary JSON values in GraphQL.

func (JSON) ImplementsGraphQLType

func (JSON) ImplementsGraphQLType(name string) bool

ImplementsGraphQLType maps this Go type to the GraphQL scalar type.

func (JSON) MarshalJSON

func (j JSON) MarshalJSON() ([]byte, error)

MarshalJSON serializes the JSON scalar to JSON.

func (*JSON) UnmarshalGraphQL

func (j *JSON) UnmarshalGraphQL(input any) error

UnmarshalGraphQL parses a JSON value from an input.

type UUID

type UUID struct {
	uuid.UUID
}

UUID is a custom scalar for uuid.UUID values in GraphQL.

func (UUID) ImplementsGraphQLType

func (UUID) ImplementsGraphQLType(name string) bool

ImplementsGraphQLType maps this Go type to the GraphQL scalar type.

func (UUID) MarshalJSON

func (u UUID) MarshalJSON() ([]byte, error)

MarshalJSON serializes a UUID to JSON.

func (*UUID) UnmarshalGraphQL

func (u *UUID) UnmarshalGraphQL(input any) error

UnmarshalGraphQL parses a UUID from an input value.

Jump to

Keyboard shortcuts

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