Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DecodeRequestFunc ¶
DecodeRequestFunc extracts a user-domain request object from a GraphQL request. It's designed to be used in GraphQL servers, for server-side endpoints. One straightforward DecodeRequestFunc could be something that decodes from the GraphQL request message to the concrete request type.
type EncodeErrorResponseFunc ¶
EncodeErrorResponseFunc transforms the passed error to a GraphQL error. It's designed to be used in GraphQL servers, for server-side endpoints.
type EncodeResponseFunc ¶
EncodeResponseFunc encodes the passed response object to the GraphQL response message. It's designed to be used in GraphQL servers, for server-side endpoints. One straightforward EncodeResponseFunc could be something that encodes the object directly to the GraphQL response message.
func ErrorResponseEncoder ¶
func ErrorResponseEncoder( encoder EncodeResponseFunc, errorEncoder EncodeErrorResponseFunc, ) EncodeResponseFunc
ErrorResponseEncoder encodes the passed response object to a GraphQL response or error.
type Handler ¶
type Handler interface {
ServeGraphQL(ctx context.Context, request interface{}) (context.Context, interface{}, error)
}
Handler which should be called from the GraphQL binding of the service implementation. The incoming request parameter, and returned response parameter, are both GraphQL types, not user-domain.
func NewErrorEncoderHandler ¶
func NewErrorEncoderHandler(handler Handler, errorEncoder EncodeErrorResponseFunc) Handler
NewErrorEncoderHandler wraps a GraphQL handler and encodes the returned error using the error encoder (if necessary).
For example, a returned endpoint error might need additional encoding.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server wraps an endpoint and implements graphql.Handler.
func NewServer ¶
func NewServer( e endpoint.Endpoint, dec DecodeRequestFunc, enc EncodeResponseFunc, opts ...ServerOption, ) *Server
NewServer constructs a new server, which implements wraps the provided endpoint and implements the Handler interface. Consumers should write bindings that adapt the concrete GraphQL queries and methods in the schema. Request and response objects are from the caller business domain, not GraphQL input and response types.
type ServerOption ¶
type ServerOption interface {
// contains filtered or unexported methods
}
ServerOption sets an optional parameter for servers.
func ServerErrorHandler ¶
func ServerErrorHandler(errorHandler transport.ErrorHandler) ServerOption
ServerErrorHandler is used to handle non-terminal errors. By default, non-terminal errors are ignored.