package thistle
import "git.sr.ht/~adnano/thistle"
Index ¶
- Variables
- func AddHeader(ctx context.Context, key, value string) context.Context
- type Client
- func NewClient(hc *http.Client) *Client
- func (c *Client) Execute(ctx context.Context, url string, op *Operation, data interface{}) error
- func (c *Client) WithUserAgent(userAgent string) *Client
- type Gateway
- func NewGateway() *Gateway
- func (g *Gateway) Complexity(typeName, fieldName string, childComplexity int, args map[string]interface{}) (int, bool)
- func (g *Gateway) Exec(ctx context.Context) graphql.ResponseHandler
- func (g *Gateway) Execute(ctx context.Context) *graphql.Response
- func (g *Gateway) Schema() *ast.Schema
- func (g *Gateway) SetSchema(schema *Schema)
- func (g *Gateway) WithClient(client *Client) *Gateway
- func (g *Gateway) WithDebugExtensions(enabled bool) *Gateway
- func (g *Gateway) WithMaxRequests(maxRequests int64) *Gateway
- type Operation
- type Response
- type Schema
- func BuildSchema(services ...*Service) (*Schema, error)
- func (s *Schema) HasField(location, typeName, field string) bool
- func (s *Schema) IsEntity(typeName string) bool
- func (s *Schema) IsKey(typeName string, field string) bool
- func (s *Schema) Key(typeName string) []string
- func (s *Schema) Requires(typeName string, field string) []string
- func (s *Schema) Route(parentType string, parentLocation string, input ast.SelectionSet) (map[string]ast.SelectionSet, error)
- type Service
- func NewService(name, url string) *Service
- func (s *Service) Name() string
- func (s *Service) SDL() string
- func (s *Service) SetSDL(sdl string) error
- func (s *Service) Status() Status
- func (s *Service) URL() string
- func (s *Service) Update(ctx context.Context, client *Client) (bool, error)
- type Status
Variables ¶
Functions ¶
func AddHeader ¶
AddHeader adds a HTTP header to downstream GraphQL requests for the current GraphQL operation.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a GraphQL client.
func NewClient ¶
NewClient creates a new GraphQL client.
If hc is nil, http.DefaultClient will be used.
func (*Client) Execute ¶
Execute executes a GraphQL operation.
The data returned by the server will be decoded into the data argument.
func (*Client) WithUserAgent ¶
WithUserAgent sets the user agent used by the client.
type Gateway ¶
type Gateway struct {
// contains filtered or unexported fields
}
Gateway is a GraphQL federation gateway.
Gateway implements gqlgen/graphql.ExecutableSchema.
func NewGateway ¶
func NewGateway() *Gateway
NewGateway creates a new GraphQL federation gateway.
func (*Gateway) Complexity ¶
func (g *Gateway) Complexity(typeName, fieldName string, childComplexity int, args map[string]interface{}) (int, bool)
Complexity returns the query complexity (unimplemented)
func (*Gateway) Exec ¶
func (g *Gateway) Exec(ctx context.Context) graphql.ResponseHandler
Exec returns the execution handler.
func (*Gateway) Execute ¶
Execute executes a GraphQL operation.
func (*Gateway) Schema ¶
Schema returns the federated schema.
func (*Gateway) SetSchema ¶
SetSchema sets the federated schema used by the gateway.
SetSchema is safe for concurrent use by multiple goroutines.
func (*Gateway) WithClient ¶
WithClient configures the client used for downstream GraphQL operations.
func (*Gateway) WithDebugExtensions ¶
WithDebugExtensions configures debugging information for GraphQL requests.
If enabled, debug information will be added to the response extensions. The following information will be provided:
- plan: the query plan, including services and subqueries
- timings: the execution times for the query
func (*Gateway) WithMaxRequests ¶
WithMaxRequests configures the maximum number of requests to make per query.
type Operation ¶
type Operation struct { Name string `json:"operationName,omitempty"` Query string `json:"query"` Variables map[string]interface{} `json:"variables,omitempty"` Uploads map[string]graphql.Upload `json:"-"` }
Operation is a GraphQL operation.
type Response ¶
Response is a GraphQL response.
type Schema ¶
Schema represents a federated GraphQL schema.
func BuildSchema ¶
BuildSchema builds and returns a new federated GraphQL schema.
func (*Schema) HasField ¶
HasField reports whether the given location can resolve the given field.
func (*Schema) IsEntity ¶
IsEntity reports whether the given type is an entity type.
func (*Schema) IsKey ¶
IsKey reports whether the given field is a key field.
func (*Schema) Key ¶
Key returns a list of key fields for the given entity type.
func (*Schema) Requires ¶
Requires returns a list of fields required by the given field.
func (*Schema) Route ¶
func (s *Schema) Route(parentType string, parentLocation string, input ast.SelectionSet) (map[string]ast.SelectionSet, error)
Route routes a selection set by location.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is a downstream GraphQL service.
func NewService ¶
NewService creates a new downstream service.
func (*Service) Name ¶
Name returns the downstream service name.
func (*Service) SDL ¶
SDL returns the downstream service definition.
func (*Service) SetSDL ¶
SetSDL sets the service definition for the downstream service.
func (*Service) Status ¶
Status returns the downstream service status.
func (*Service) URL ¶
URL returns the downstream service URL.
func (*Service) Update ¶
Update fetches and validates the service definition from downstream and reports whether the service definition was updated.
type Status ¶
type Status int
Status represents the status of a downstream service.
Source Files ¶
client.go directives.go execution.go format.go gateway.go introspection.go plan.go schema.go service.go
Directories ¶
Path | Synopsis |
---|---|
admin | |
fieldset | Package fieldset provides functions for parsing _FieldSet scalars. |
- Version
- v0.0.0-20230629043621-3712696d8056 (latest)
- Published
- Jun 29, 2023
- Platform
- linux/amd64
- Imports
- 28 packages
- Last checked
- 2 months ago –
Tools for package owners.