runtime

package
v0.0.0-...-03f1f23 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalRequest

func MarshalRequest(args, v interface{}, isCamel bool) error

MarshalRequest marshals graphql request arguments to gRPC request message

func MarshalResponse

func MarshalResponse(resp interface{}) interface{}

Types

type GraphqlError

type GraphqlError = gqlerrors.FormattedError

Type alias for gqlerrors in order to avoid to import gqlerrors in user's application

type GraphqlErrorHandler

type GraphqlErrorHandler func(errs []GraphqlError)

Custom error handler which is called on graphql result has an error

type GraphqlHandler

type GraphqlHandler interface {
	CreateConnection(context.Context) (*grpc.ClientConn, func(), error)
	GetMutations(*grpc.ClientConn) graphql.Fields
	GetQueries(*grpc.ClientConn) graphql.Fields
}

type GraphqlRequest

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

type MiddlewareError

type MiddlewareError struct {
	Code    string
	Message string
}

func NewMiddlewareError

func NewMiddlewareError(code, message string) *MiddlewareError

func (*MiddlewareError) Error

func (m *MiddlewareError) Error() string

type MiddlewareFunc

type MiddlewareFunc func(ctx context.Context, w http.ResponseWriter, r *http.Request) (context.Context, error)

MiddlewareFunc type definition

func Cors

func Cors() MiddlewareFunc

Cors is middelware function to provide CORS headers to response headers

type ServeMux

type ServeMux struct {
	ErrorHandler GraphqlErrorHandler
	// contains filtered or unexported fields
}

ServeMux is struct can execute graphql request via incoming HTTP request. This is inspired from grpc-gateway implementation, thanks!

func NewServeMux

func NewServeMux(ms ...MiddlewareFunc) *ServeMux

NewServeMux creates ServeMux pointer

func (*ServeMux) AddHandler

func (s *ServeMux) AddHandler(h GraphqlHandler) error

AddHandler registers graphql handler which is built via plugin

func (*ServeMux) ServeHTTP

func (s *ServeMux) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler

func (*ServeMux) Use

func (s *ServeMux) Use(ms ...MiddlewareFunc) *ServeMux

Use adds more middlwares

Jump to

Keyboard shortcuts

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