Documentation ¶
Index ¶
- Variables
- func ApplyFragments(selectionSet ast.SelectionSet, fragmentDefs ast.FragmentDefinitionList) (ast.SelectionSet, error)
- func ExtractVariables(args ast.ArgumentList) []string
- func FormatSelectionSet(selection ast.SelectionSet) string
- func IntrospectAPI(queryer Queryer, opts ...*IntrospectOptions) (*ast.Schema, error)
- func LoadSchema(typedef string) (*ast.Schema, error)
- func PrintQuery(document *ast.QueryDocument) (string, error)
- func SelectedFields(source ast.SelectionSet) []*ast.Field
- type CountRetrier
- type Error
- type ErrorList
- type File
- type HTTPQueryer
- type HTTPQueryerWithMiddlewares
- type IntrospectOptions
- type IntrospectionInputValue
- type IntrospectionQueryDirective
- type IntrospectionQueryEnumDefinition
- type IntrospectionQueryFullType
- type IntrospectionQueryFullTypeField
- type IntrospectionQueryResult
- type IntrospectionQueryRootType
- type IntrospectionQuerySchema
- type IntrospectionTypeRef
- type MockSuccessQueryer
- type MultiOpQueryer
- type NetworkMiddleware
- type NetworkQueryer
- type QueryInput
- type Queryer
- type QueryerFunc
- type QueryerWithMiddlewares
- type RemoteSchema
- type Retrier
- type SingleRequestQueryer
- func (q *SingleRequestQueryer) Query(ctx context.Context, input *QueryInput, receiver interface{}) error
- func (q *SingleRequestQueryer) URL() string
- func (q *SingleRequestQueryer) WithHTTPClient(client *http.Client) Queryer
- func (q *SingleRequestQueryer) WithMiddlewares(mwares []NetworkMiddleware) Queryer
- type Upload
- type UploadMap
Constants ¶
This section is empty.
Variables ¶
var IntrospectionQuery = `` /* 1141-byte string literal not displayed */
IntrospectionQuery is the query that is fired at an API to reconstruct its schema
Functions ¶
func ApplyFragments ¶
func ApplyFragments(selectionSet ast.SelectionSet, fragmentDefs ast.FragmentDefinitionList) (ast.SelectionSet, error)
ApplyFragments takes a list of selections and merges them into one, embedding any fragments it runs into along the way
func ExtractVariables ¶
func ExtractVariables(args ast.ArgumentList) []string
ExtractVariables takes a list of arguments and returns a list of every variable used
func FormatSelectionSet ¶
func FormatSelectionSet(selection ast.SelectionSet) string
FormatSelectionSet returns a pretty printed version of a selection set
func IntrospectAPI ¶
func IntrospectAPI(queryer Queryer, opts ...*IntrospectOptions) (*ast.Schema, error)
IntrospectAPI send the introspection query to a Queryer and builds up the schema object described by the result
func LoadSchema ¶
LoadSchema takes an SDL string and returns the parsed version
func PrintQuery ¶
func PrintQuery(document *ast.QueryDocument) (string, error)
PrintQuery creates a string representation of an operation
func SelectedFields ¶
func SelectedFields(source ast.SelectionSet) []*ast.Field
Types ¶
type CountRetrier ¶
type CountRetrier struct {
// contains filtered or unexported fields
}
CountRetrier is a Retrier that stops after a number of attempts.
func NewCountRetrier ¶
func NewCountRetrier(maxRetries uint) CountRetrier
NewCountRetrier returns a CountRetrier with the given maximum number of retries beyond the first attempt.
func (CountRetrier) ShouldRetry ¶
func (c CountRetrier) ShouldRetry(err error, attempts uint) bool
type Error ¶
type Error struct { Extensions map[string]interface{} `json:"extensions"` Message string `json:"message"` Path []interface{} `json:"path,omitempty"` }
Error represents a graphql error
type HTTPQueryer ¶
HTTPQueryer is an interface for queryers that let you configure an underlying http.Client
type HTTPQueryerWithMiddlewares ¶
type HTTPQueryerWithMiddlewares interface { WithHTTPClient(client *http.Client) Queryer WithMiddlewares(wares []NetworkMiddleware) Queryer }
HTTPQueryerWithMiddlewares is an interface for queryers that let you configure an underlying http.Client and accept middlewares
type IntrospectOptions ¶
type IntrospectOptions struct {
// contains filtered or unexported fields
}
IntrospectOptions represents the options for the IntrospectAPI function
func IntrospectWithContext ¶
func IntrospectWithContext(ctx context.Context) *IntrospectOptions
IntrospectWithHTTPClient returns an instance of graphql.IntrospectOptions with given context to be used as a parameter for graphql.Queryer.Query function in the graphql.IntrospectAPI function
func IntrospectWithHTTPClient ¶
func IntrospectWithHTTPClient(client *http.Client) *IntrospectOptions
IntrospectWithHTTPClient returns an instance of graphql.IntrospectOptions with given client to be pass to an instance of a graphql.Queryer by the IntrospectOptions.Apply function
func IntrospectWithMiddlewares ¶
func IntrospectWithMiddlewares(wares ...NetworkMiddleware) *IntrospectOptions
IntrospectWithMiddlewares returns an instance of graphql.IntrospectOptions with given middlewares to be pass to an instance of a graphql.Queryer by the IntrospectOptions.Apply function
func IntrospectWithRetrier ¶
func IntrospectWithRetrier(retrier Retrier) *IntrospectOptions
IntrospectWithRetrier returns an instance of graphql.IntrospectOptions with the given Retrier. For a fixed number of retries, see CountRetrier.
func (*IntrospectOptions) Apply ¶
func (o *IntrospectOptions) Apply(queryer Queryer) Queryer
Apply applies the options to a given queryer
func (*IntrospectOptions) Context ¶
func (o *IntrospectOptions) Context() context.Context
Context returns either a given context or an instance of the context.Background
type IntrospectionInputValue ¶
type IntrospectionInputValue struct { Name string `json:"name"` Description string `json:"description"` DefaultValue string `json:"defaultValue"` Type IntrospectionTypeRef `json:"type"` }
type IntrospectionQueryDirective ¶
type IntrospectionQueryDirective struct { Name string `json:"name"` Description string `json:"description"` Locations []string `json:"locations"` Args []IntrospectionInputValue `json:"args"` }
type IntrospectionQueryFullType ¶
type IntrospectionQueryFullType struct { Kind string `json:"kind"` Name string `json:"name"` Description string `json:"description"` InputFields []IntrospectionInputValue `json:"inputFields"` Interfaces []IntrospectionTypeRef `json:"interfaces"` PossibleTypes []IntrospectionTypeRef `json:"possibleTypes"` Fields []IntrospectionQueryFullTypeField `json:"fields"` EnumValues []IntrospectionQueryEnumDefinition `json:"enumValues"` }
type IntrospectionQueryFullTypeField ¶
type IntrospectionQueryFullTypeField struct { Name string `json:"name"` Description string `json:"description"` Args []IntrospectionInputValue `json:"args"` Type IntrospectionTypeRef `json:"type"` IsDeprecated bool `json:"isDeprecated"` DeprecationReason string `json:"deprecationReason"` }
type IntrospectionQueryResult ¶
type IntrospectionQueryResult struct {
Schema *IntrospectionQuerySchema `json:"__schema"`
}
type IntrospectionQueryRootType ¶
type IntrospectionQueryRootType struct {
Name string `json:"name"`
}
type IntrospectionQuerySchema ¶
type IntrospectionQuerySchema struct { QueryType IntrospectionQueryRootType `json:"queryType"` MutationType *IntrospectionQueryRootType `json:"mutationType"` SubscriptionType *IntrospectionQueryRootType `json:"subscriptionType"` Types []IntrospectionQueryFullType `json:"types"` Directives []IntrospectionQueryDirective `json:"directives"` }
type IntrospectionTypeRef ¶
type IntrospectionTypeRef struct { Kind string `json:"kind"` Name string `json:"name"` OfType *IntrospectionTypeRef `json:"ofType"` }
type MockSuccessQueryer ¶
type MockSuccessQueryer struct {
Value interface{}
}
MockSuccessQueryer responds with pre-defined value when executing a query
func (*MockSuccessQueryer) Query ¶
func (q *MockSuccessQueryer) Query(ctx context.Context, input *QueryInput, receiver interface{}) error
Query looks up the name of the query in the map of responses and returns the value
type MultiOpQueryer ¶
type MultiOpQueryer struct { MaxBatchSize int BatchInterval time.Duration // contains filtered or unexported fields }
MultiOpQueryer is a queryer that will batch subsequent query on some interval into a single network request to a single target
func NewMultiOpQueryer ¶
func NewMultiOpQueryer(url string, interval time.Duration, maxBatchSize int) *MultiOpQueryer
NewMultiOpQueryer returns a MultiOpQueryer with the provided parameters
func (*MultiOpQueryer) Query ¶
func (q *MultiOpQueryer) Query(ctx context.Context, input *QueryInput, receiver interface{}) error
Query bundles queries that happen within the given interval into a single network request whose body is a list of the operation payload.
func (*MultiOpQueryer) WithHTTPClient ¶
func (q *MultiOpQueryer) WithHTTPClient(client *http.Client) Queryer
WithHTTPClient lets the user configure the client to use when making network requests
func (*MultiOpQueryer) WithMiddlewares ¶
func (q *MultiOpQueryer) WithMiddlewares(mwares []NetworkMiddleware) Queryer
WithMiddlewares lets the user assign middlewares to the queryer
type NetworkMiddleware ¶
NetworkMiddleware are functions can be passed to SingleRequestQueryer.WithMiddleware to affect its internal behavior
type NetworkQueryer ¶
type NetworkQueryer struct { URL string Middlewares []NetworkMiddleware Client *http.Client }
func (*NetworkQueryer) ExtractErrors ¶
func (q *NetworkQueryer) ExtractErrors(result map[string]interface{}) error
ExtractErrors takes the result from a remote query and writes it to the provided pointer
func (*NetworkQueryer) SendMultipart ¶
func (q *NetworkQueryer) SendMultipart(ctx context.Context, payload []byte, contentType string) ([]byte, error)
SendMultipart is responsible for sending multipart request to the desingated URL
type QueryInput ¶
type QueryInput struct { Query string `json:"query"` QueryDocument *ast.QueryDocument `json:"-"` OperationName string `json:"operationName"` Variables map[string]interface{} `json:"variables"` }
QueryInput provides all of the information required to fire a query
func (*QueryInput) Raw ¶
func (i *QueryInput) Raw() interface{}
Raw returns the "raw underlying value of the key" when used by dataloader
func (*QueryInput) String ¶
func (i *QueryInput) String() string
String returns a guaranteed unique string that can be used to identify the input
type Queryer ¶
type Queryer interface {
Query(context.Context, *QueryInput, interface{}) error
}
Queryer is a interface for objects that can perform
type QueryerFunc ¶
type QueryerFunc func(*QueryInput) (interface{}, error)
QueryerFunc responds to the query by calling the provided function
func (QueryerFunc) Query ¶
func (q QueryerFunc) Query(ctx context.Context, input *QueryInput, receiver interface{}) error
Query invokes the provided function and writes the response to the receiver
type QueryerWithMiddlewares ¶
type QueryerWithMiddlewares interface {
WithMiddlewares(wares []NetworkMiddleware) Queryer
}
QueryerWithMiddlewares is an interface for queryers that support network middlewares
type RemoteSchema ¶
RemoteSchema encapsulates a particular schema that can be executed by sending network requests to the specified URL.
func IntrospectRemoteSchema ¶
func IntrospectRemoteSchema(url string, opts ...*IntrospectOptions) (*RemoteSchema, error)
IntrospectRemoteSchema is used to build a RemoteSchema by firing the introspection query at a remote service and reconstructing the schema object from the response
func IntrospectRemoteSchemas ¶
func IntrospectRemoteSchemas(urls ...string) ([]*RemoteSchema, error)
IntrospectRemoteSchemas takes a list of URLs and creates a RemoteSchema by invoking graphql.IntrospectRemoteSchema at that location.
func IntrospectRemoteSchemasWithOptions ¶
func IntrospectRemoteSchemasWithOptions(urls []string, opts ...*IntrospectOptions) ([]*RemoteSchema, error)
IntrospectRemoteSchemasWithOptions takes a list of URLs and an optional list of graphql.IntrospectionOptions and creates a RemoteSchema by invoking graphql.IntrospectRemoteSchema at that location.
type Retrier ¶
type Retrier interface { // ShouldRetry returns true if another attempt should run, // given 'err' from the previous attempt and the total attempt count (starts at 1). // // Consider the 'errors' package to unwrap the error. e.g. errors.As(), errors.Is() ShouldRetry(err error, attempts uint) bool }
Retrier indicates whether or not to retry and attempt another query.
type SingleRequestQueryer ¶
type SingleRequestQueryer struct {
// contains filtered or unexported fields
}
SingleRequestQueryer sends the query to a url and returns the response
func NewSingleRequestQueryer ¶
func NewSingleRequestQueryer(url string) *SingleRequestQueryer
NewSingleRequestQueryer returns a SingleRequestQueryer pointed to the given url
func (*SingleRequestQueryer) Query ¶
func (q *SingleRequestQueryer) Query(ctx context.Context, input *QueryInput, receiver interface{}) error
Query sends the query to the designated url and returns the response.
func (*SingleRequestQueryer) URL ¶
func (q *SingleRequestQueryer) URL() string
func (*SingleRequestQueryer) WithHTTPClient ¶
func (q *SingleRequestQueryer) WithHTTPClient(client *http.Client) Queryer
WithHTTPClient lets the user configure the underlying http client being used
func (*SingleRequestQueryer) WithMiddlewares ¶
func (q *SingleRequestQueryer) WithMiddlewares(mwares []NetworkMiddleware) Queryer
WithMiddlewares returns a network queryer that will apply the provided middlewares