Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalRequest ¶
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 MiddlewareError ¶
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
Click to show internal directories.
Click to hide internal directories.