graphql

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2022 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	URL  string
	HTTP *http.Client

	Service    string
	PublicKey  ed25519.PublicKey
	PrivateKey ed25519.PrivateKey
}

A Client can be used to request GraphQL queries and mutations using HTTP.

func (*Client) ClaimTask added in v0.4.0

func (client *Client) ClaimTask(ctx context.Context, id int) (*ent.Task, error)

ClaimTask with the provided ID.

func (*Client) ClaimTasks

func (client *Client) ClaimTasks(ctx context.Context, vars models.ClaimTasksRequest) ([]*ent.Task, error)

ClaimTasks for a target that has the provided attributes, returning an array of tasks to execute. If no tasks are available, an empty task array is returned. If no target can be found, an error will be returned.

func (*Client) CreateTag added in v0.3.0

func (client *Client) CreateTag(ctx context.Context, vars models.CreateTagRequest) (*ent.Tag, error)

CreateTag will create a tag, but may error if the tag already exists.

func (*Client) CreateTags added in v0.3.0

func (client *Client) CreateTags(ctx context.Context, names ...string) (map[string]*ent.Tag, error)

CreateTags ensures that the provided set of tags exists and creates any that do not yet exist. If duplicate tag names are provided, the tag will only be created once.

func (*Client) CreateTarget added in v0.3.0

func (client *Client) CreateTarget(ctx context.Context, vars models.CreateTargetRequest) (*ent.Target, error)

CreateTarget creates a target, but may error if it already exists.

func (*Client) Do

func (client *Client) Do(ctx context.Context, request Request, dst interface{}) error

Do executes a GraphQL request and unmarshals the JSON result into the destination struct.

func (*Client) ListTags added in v0.3.0

func (client *Client) ListTags(ctx context.Context) (map[string]*ent.Tag, error)

ListTags provides a map of name to tag for all existing tags.

func (*Client) SubmitTaskResult

func (client *Client) SubmitTaskResult(ctx context.Context, vars models.SubmitTaskResultRequest) error

SubmitTaskResult updates a task with execution output.

type Error

type Error struct {
	Message string   `json:"message"`
	Path    []string `json:"path"`
}

An Error returned by the GraphQL server

func (Error) Error

func (err Error) Error() string

Error implements the error interface by formatting an error message of the available error info.

type MutationResolver added in v0.3.0

type MutationResolver generated.MutationResolver

MutationResolver is an alias for github.com/kcarretto/paragon/graphql/generated.MutationResolver

type QueryResolver added in v0.3.0

type QueryResolver generated.QueryResolver

QueryResolver is an alias for github.com/kcarretto/paragon/graphql/generated.QueryResolver

type Request

type Request struct {
	Operation string      `json:"operationName"`
	Query     string      `json:"query"`
	Variables interface{} `json:"variables,omitempty"`
}

A Request stores execution properties of GraphQL queries and mutations.

type Service added in v0.3.0

type Service struct {
	Log    *zap.Logger
	Graph  *ent.Client
	Events event.Publisher
	Auth   service.Authenticator
}

Service provides HTTP handlers for the GraphQL schema.

func (*Service) HTTP added in v0.3.0

func (svc *Service) HTTP(router *http.ServeMux)

HTTP registers http handlers for a GraphQL API.

func (*Service) HandleGraphQL added in v0.3.0

func (svc *Service) HandleGraphQL() http.HandlerFunc

HandleGraphQL initializes and returns a new GraphQL API handler.

func (*Service) HandlePlayground added in v0.3.0

func (svc *Service) HandlePlayground() http.HandlerFunc

HandlePlayground initializes and returns a new GraphQL Playground handler.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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