Documentation
¶
Index ¶
- type Client
- func (c *Client) Call(resolver interface{}, callback interface{}, args ...interface{}) error
- func (c *Client) Mutate(ctx context.Context, mutation string, variables map[string]interface{}, ...) error
- func (c *Client) Query(ctx context.Context, query string, variables map[string]interface{}, ...) error
- func (c *Client) Subscribe(ctx context.Context, subscription string, variables map[string]interface{}, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func New ¶
NewClient creates a new GraphQL client with the specified HTTP and WebSocket endpoints. It initializes the HTTP client and stores the endpoints for later use.
func (*Client) Call ¶
Call is a generic function that executes a GraphQL operation (query, mutation, or subscription) based on the provided resolver function. It validates the callback and arguments, then calls the appropriate execution function.
func (*Client) Mutate ¶
func (c *Client) Mutate(ctx context.Context, mutation string, variables map[string]interface{}, result interface{}) error
Mutate sends a GraphQL mutation to the server and unmarshals the response into the result parameter. It takes a context for cancellation, the mutation string, a map of variables, and a pointer to the result.
func (*Client) Query ¶
func (c *Client) Query(ctx context.Context, query string, variables map[string]interface{}, result interface{}) error
Query sends a GraphQL query to the server and unmarshals the response into the result parameter. It takes a context for cancellation, the query string, a map of variables, and a pointer to the result.
func (*Client) Subscribe ¶
func (c *Client) Subscribe(ctx context.Context, subscription string, variables map[string]interface{}, handler func([]byte) error) error
Subscribe initiates a GraphQL subscription over a WebSocket connection. It takes a context for cancellation, the subscription string, a map of variables, and a handler function to process incoming messages.