Documentation ¶
Index ¶
- Constants
- Variables
- func CreateTypeFieldArgumentsLookupMap(typeFieldArgs []TypeFieldArguments) map[TypeFieldLookupKey]TypeFieldArguments
- func UnmarshalHttpRequest(r *http.Request, request *Request) error
- func UnmarshalRequest(reader io.Reader, request *Request) error
- type ComplexityCalculator
- type ComplexityResult
- type DataSourceGraphqlOptions
- type DataSourceHttpJsonOptions
- type DefaultFieldsValidator
- func (d DefaultFieldsValidator) Validate(request *Request, schema *Schema, restrictions []Type) (RequestFieldsValidationResult, error)deprecated
- func (d DefaultFieldsValidator) ValidateByFieldList(request *Request, schema *Schema, restrictionList FieldRestrictionList) (RequestFieldsValidationResult, error)
- type EngineResultWriter
- func (e *EngineResultWriter) AsHTTPResponse(status int, headers http.Header) *http.Response
- func (e *EngineResultWriter) Bytes() []byte
- func (e *EngineResultWriter) Flush()
- func (e *EngineResultWriter) Len() int
- func (e *EngineResultWriter) Read(p []byte) (n int, err error)
- func (e *EngineResultWriter) Reset()
- func (e *EngineResultWriter) SetFlushCallback(flushCb func(data []byte))
- func (e *EngineResultWriter) String() string
- func (e *EngineResultWriter) Write(p []byte) (n int, err error)
- type EngineV2Configuration
- func (e *EngineV2Configuration) AddDataSource(dataSource plan.DataSourceConfiguration)
- func (e *EngineV2Configuration) AddFieldConfiguration(fieldConfig plan.FieldConfiguration)
- func (e *EngineV2Configuration) DataSources() []plan.DataSourceConfiguration
- func (e *EngineV2Configuration) EnableDataLoader(enable bool)
- func (e *EngineV2Configuration) FieldConfigurations() plan.FieldConfigurations
- func (e *EngineV2Configuration) SetDataSources(dataSources []plan.DataSourceConfiguration)
- func (e *EngineV2Configuration) SetFieldConfigurations(fieldConfigs plan.FieldConfigurations)
- func (e *EngineV2Configuration) SetWebsocketBeforeStartHook(hook WebsocketBeforeStartHook)
- type ErrorPath
- type Errors
- type ExecutionEngine
- func (e *ExecutionEngine) AddDataSource(name string, plannerFactoryFactory datasource.PlannerFactoryFactory) error
- func (e *ExecutionEngine) AddGraphqlDataSource(name string) error
- func (e *ExecutionEngine) AddGraphqlDataSourceWithOptions(name string, options DataSourceGraphqlOptions) error
- func (e *ExecutionEngine) AddHttpJsonDataSource(name string) error
- func (e *ExecutionEngine) AddHttpJsonDataSourceWithOptions(name string, options DataSourceHttpJsonOptions) error
- func (e *ExecutionEngine) Execute(ctx context.Context, operation *Request, options ExecutionOptions) (*ExecutionResult, error)
- func (e *ExecutionEngine) ExecuteWithWriter(ctx context.Context, operation *Request, writer io.Writer, ...) error
- func (e *ExecutionEngine) NewExecutionHandler() *execution.Handler
- type ExecutionEngineV2
- type ExecutionOptions
- type ExecutionOptionsV2
- type ExecutionResult
- type Extractor
- type FederationEngineConfigFactory
- type FederationEngineConfigFactoryOption
- type FieldComplexityResult
- type FieldRestrictionList
- type FieldRestrictionListKind
- type FieldRestrictionValidator
- type NormalizationResult
- type OperationType
- type ProxyEngineConfigFactory
- type ProxyEngineConfigFactoryOption
- type ProxyUpstreamConfig
- type Request
- func (r *Request) CalculateComplexity(complexityCalculator ComplexityCalculator, schema *Schema) (ComplexityResult, error)
- func (r *Request) IsIntrospectionQuery() (result bool, err error)
- func (r *Request) IsNormalized() bool
- func (r *Request) Normalize(schema *Schema) (result NormalizationResult, err error)
- func (r *Request) OperationType() (OperationType, error)
- func (r Request) Print(writer io.Writer) (n int, err error)
- func (r *Request) SetHeader(header http.Header)
- func (r *Request) ValidateFieldRestrictions(schema *Schema, restrictedFieldsList FieldRestrictionList, ...) (RequestFieldsValidationResult, error)
- func (r *Request) ValidateForSchema(schema *Schema) (result ValidationResult, err error)
- func (r *Request) ValidateRestrictedFields(schema *Schema, restrictedFields []Type) (RequestFieldsValidationResult, error)deprecated
- type RequestError
- type RequestErrors
- type RequestFields
- type RequestFieldsValidationResult
- type RequestFieldsValidator
- type RequestTypes
- type Response
- type Schema
- func (s *Schema) Document() []byte
- func (s *Schema) GetAllFieldArguments(skipFieldFuncs ...SkipFieldFunc) []TypeFieldArguments
- func (s *Schema) GetAllNestedFieldChildrenFromTypeField(typeName string, fieldName string, skipFieldFuncs ...SkipFieldFunc) []TypeFields
- func (s *Schema) HasMutationType() bool
- func (s *Schema) HasQueryType() bool
- func (s *Schema) HasSubscriptionType() bool
- func (s *Schema) Hash() (uint64, error)
- func (s *Schema) Input() []byte
- func (s *Schema) IntrospectionResponse(out io.Writer) error
- func (s *Schema) IsNormalized() bool
- func (s *Schema) MutationTypeName() string
- func (s *Schema) Normalize() (result NormalizationResult, err error)
- func (s *Schema) QueryTypeName() string
- func (s *Schema) SubscriptionTypeName() string
- func (s *Schema) Validate() (result ValidationResult, err error)
- type SchemaValidationError
- type SchemaValidationErrors
- type SkipFieldFunc
- type Type
- type TypeFieldArguments
- type TypeFieldLookupKey
- type TypeFields
- type ValidationResult
- type WebsocketBeforeStartHook
Constants ¶
const (
DefaultFlushIntervalInMilliseconds = 1000
)
Variables ¶
var ( ErrEmptyRequest = errors.New("the provided request is empty") ErrNilSchema = errors.New("the provided schema is nil") )
var DefaultComplexityCalculator = defaultComplexityCalculator{}
Functions ¶
func CreateTypeFieldArgumentsLookupMap ¶
func CreateTypeFieldArgumentsLookupMap(typeFieldArgs []TypeFieldArguments) map[TypeFieldLookupKey]TypeFieldArguments
Types ¶
type ComplexityCalculator ¶
type ComplexityCalculator interface {
Calculate(operation, definition *ast.Document) (ComplexityResult, error)
}
type ComplexityResult ¶
type ComplexityResult struct { NodeCount int Complexity int Depth int PerRootField []FieldComplexityResult Errors Errors }
type DataSourceGraphqlOptions ¶
type DataSourceGraphqlOptions struct { HttpClient *http.Client WhitelistedSchemes []string Hooks *datasource.Hooks }
type DataSourceHttpJsonOptions ¶
type DataSourceHttpJsonOptions struct { HttpClient *http.Client WhitelistedSchemes []string Hooks *datasource.Hooks }
type DefaultFieldsValidator ¶
type DefaultFieldsValidator struct { }
func (DefaultFieldsValidator) Validate
deprecated
func (d DefaultFieldsValidator) Validate(request *Request, schema *Schema, restrictions []Type) (RequestFieldsValidationResult, error)
Validate validates a request by checking if `restrictions` contains blocked fields.
Deprecated: This function can only handle blocked fields. Use `ValidateByFieldList` if you want to check for blocked or allowed fields instead.
func (DefaultFieldsValidator) ValidateByFieldList ¶
func (d DefaultFieldsValidator) ValidateByFieldList(request *Request, schema *Schema, restrictionList FieldRestrictionList) (RequestFieldsValidationResult, error)
ValidateByFieldList will validate a request by using a list of allowed or blocked fields.
type EngineResultWriter ¶
type EngineResultWriter struct {
// contains filtered or unexported fields
}
func NewEngineResultWriter ¶
func NewEngineResultWriter() EngineResultWriter
func NewEngineResultWriterFromBuffer ¶
func NewEngineResultWriterFromBuffer(buf *bytes.Buffer) EngineResultWriter
func (*EngineResultWriter) AsHTTPResponse ¶
func (*EngineResultWriter) Bytes ¶
func (e *EngineResultWriter) Bytes() []byte
func (*EngineResultWriter) Flush ¶
func (e *EngineResultWriter) Flush()
func (*EngineResultWriter) Len ¶
func (e *EngineResultWriter) Len() int
func (*EngineResultWriter) Reset ¶
func (e *EngineResultWriter) Reset()
func (*EngineResultWriter) SetFlushCallback ¶
func (e *EngineResultWriter) SetFlushCallback(flushCb func(data []byte))
func (*EngineResultWriter) String ¶
func (e *EngineResultWriter) String() string
type EngineV2Configuration ¶
type EngineV2Configuration struct {
// contains filtered or unexported fields
}
func NewEngineV2Configuration ¶
func NewEngineV2Configuration(schema *Schema) EngineV2Configuration
func (*EngineV2Configuration) AddDataSource ¶
func (e *EngineV2Configuration) AddDataSource(dataSource plan.DataSourceConfiguration)
func (*EngineV2Configuration) AddFieldConfiguration ¶
func (e *EngineV2Configuration) AddFieldConfiguration(fieldConfig plan.FieldConfiguration)
func (*EngineV2Configuration) DataSources ¶
func (e *EngineV2Configuration) DataSources() []plan.DataSourceConfiguration
func (*EngineV2Configuration) EnableDataLoader ¶
func (e *EngineV2Configuration) EnableDataLoader(enable bool)
func (*EngineV2Configuration) FieldConfigurations ¶
func (e *EngineV2Configuration) FieldConfigurations() plan.FieldConfigurations
func (*EngineV2Configuration) SetDataSources ¶
func (e *EngineV2Configuration) SetDataSources(dataSources []plan.DataSourceConfiguration)
func (*EngineV2Configuration) SetFieldConfigurations ¶
func (e *EngineV2Configuration) SetFieldConfigurations(fieldConfigs plan.FieldConfigurations)
func (*EngineV2Configuration) SetWebsocketBeforeStartHook ¶
func (e *EngineV2Configuration) SetWebsocketBeforeStartHook(hook WebsocketBeforeStartHook)
SetWebsocketBeforeStartHook - sets before start hook which will be called before processing any operation sent over websockets
type ErrorPath ¶
type ErrorPath struct {
// contains filtered or unexported fields
}
func (*ErrorPath) MarshalJSON ¶
type ExecutionEngine ¶
type ExecutionEngine struct {
// contains filtered or unexported fields
}
func NewExecutionEngine ¶
func NewExecutionEngine(logger abstractlogger.Logger, schema *Schema, plannerConfig datasource.PlannerConfiguration) (*ExecutionEngine, error)
func (*ExecutionEngine) AddDataSource ¶
func (e *ExecutionEngine) AddDataSource(name string, plannerFactoryFactory datasource.PlannerFactoryFactory) error
func (*ExecutionEngine) AddGraphqlDataSource ¶
func (e *ExecutionEngine) AddGraphqlDataSource(name string) error
func (*ExecutionEngine) AddGraphqlDataSourceWithOptions ¶
func (e *ExecutionEngine) AddGraphqlDataSourceWithOptions(name string, options DataSourceGraphqlOptions) error
func (*ExecutionEngine) AddHttpJsonDataSource ¶
func (e *ExecutionEngine) AddHttpJsonDataSource(name string) error
func (*ExecutionEngine) AddHttpJsonDataSourceWithOptions ¶
func (e *ExecutionEngine) AddHttpJsonDataSourceWithOptions(name string, options DataSourceHttpJsonOptions) error
func (*ExecutionEngine) Execute ¶
func (e *ExecutionEngine) Execute(ctx context.Context, operation *Request, options ExecutionOptions) (*ExecutionResult, error)
func (*ExecutionEngine) ExecuteWithWriter ¶
func (e *ExecutionEngine) ExecuteWithWriter(ctx context.Context, operation *Request, writer io.Writer, options ExecutionOptions) error
func (*ExecutionEngine) NewExecutionHandler ¶
func (e *ExecutionEngine) NewExecutionHandler() *execution.Handler
type ExecutionEngineV2 ¶
type ExecutionEngineV2 struct {
// contains filtered or unexported fields
}
func NewExecutionEngineV2 ¶
func NewExecutionEngineV2(ctx context.Context, logger abstractlogger.Logger, engineConfig EngineV2Configuration) (*ExecutionEngineV2, error)
func (*ExecutionEngineV2) Execute ¶
func (e *ExecutionEngineV2) Execute(ctx context.Context, operation *Request, writer resolve.FlushWriter, options ...ExecutionOptionsV2) error
func (*ExecutionEngineV2) GetWebsocketBeforeStartHook ¶
func (e *ExecutionEngineV2) GetWebsocketBeforeStartHook() WebsocketBeforeStartHook
type ExecutionOptions ¶
type ExecutionOptions struct {
ExtraArguments json.RawMessage
}
type ExecutionOptionsV2 ¶
type ExecutionOptionsV2 func(ctx *internalExecutionContext)
func WithAdditionalHttpHeaders ¶
func WithAdditionalHttpHeaders(headers http.Header, excludeByKeys ...string) ExecutionOptionsV2
func WithAfterFetchHook ¶
func WithAfterFetchHook(hook resolve.AfterFetchHook) ExecutionOptionsV2
func WithBeforeFetchHook ¶
func WithBeforeFetchHook(hook resolve.BeforeFetchHook) ExecutionOptionsV2
type ExecutionResult ¶
type ExecutionResult struct {
// contains filtered or unexported fields
}
func SchemaIntrospection ¶
func SchemaIntrospection(schema *Schema) (*ExecutionResult, error)
func (*ExecutionResult) Buffer ¶
func (r *ExecutionResult) Buffer() *bytes.Buffer
func (*ExecutionResult) GetAsHTTPResponse ¶
func (r *ExecutionResult) GetAsHTTPResponse() (res *http.Response)
type Extractor ¶
type Extractor struct {
// contains filtered or unexported fields
}
func NewExtractor ¶
func NewExtractor() *Extractor
func (*Extractor) ExtractFieldsFromRequest ¶
func (e *Extractor) ExtractFieldsFromRequest(request *Request, schema *Schema, report *operationreport.Report, data RequestTypes)
type FederationEngineConfigFactory ¶
type FederationEngineConfigFactory struct {
// contains filtered or unexported fields
}
FederationEngineConfigFactory is used to create a v2 engine config for a supergraph with multiple data sources for subgraphs.
func NewFederationEngineConfigFactory ¶
func NewFederationEngineConfigFactory(dataSourceConfigs []graphqlDataSource.Configuration, batchFactory resolve.DataSourceBatchFactory, opts ...FederationEngineConfigFactoryOption) *FederationEngineConfigFactory
func (*FederationEngineConfigFactory) EngineV2Configuration ¶
func (f *FederationEngineConfigFactory) EngineV2Configuration() (conf EngineV2Configuration, err error)
func (*FederationEngineConfigFactory) MergedSchema ¶
func (f *FederationEngineConfigFactory) MergedSchema() (*Schema, error)
func (*FederationEngineConfigFactory) SetMergedSchemaFromString ¶
func (f *FederationEngineConfigFactory) SetMergedSchemaFromString(mergedSchema string) (err error)
type FederationEngineConfigFactoryOption ¶
type FederationEngineConfigFactoryOption func(options *federationEngineConfigFactoryOptions)
func WithFederationHttpClient ¶
func WithFederationHttpClient(client *http.Client) FederationEngineConfigFactoryOption
type FieldComplexityResult ¶
type FieldRestrictionList ¶
type FieldRestrictionList struct { Kind FieldRestrictionListKind Types []Type }
type FieldRestrictionListKind ¶
type FieldRestrictionListKind int
const ( AllowList FieldRestrictionListKind = iota BlockList )
type FieldRestrictionValidator ¶
type FieldRestrictionValidator interface {
ValidateByFieldList(request *Request, schema *Schema, restrictionList FieldRestrictionList) (RequestFieldsValidationResult, error)
}
type NormalizationResult ¶
type OperationType ¶
type OperationType ast.OperationType
const ( OperationTypeUnknown OperationType = OperationType(ast.OperationTypeUnknown) OperationTypeQuery OperationType = OperationType(ast.OperationTypeQuery) OperationTypeMutation OperationType = OperationType(ast.OperationTypeMutation) OperationTypeSubscription OperationType = OperationType(ast.OperationTypeSubscription) )
type ProxyEngineConfigFactory ¶
type ProxyEngineConfigFactory struct {
// contains filtered or unexported fields
}
ProxyEngineConfigFactory is used to create a v2 engine config with a single upstream and a single data source for this upstream.
func NewProxyEngineConfigFactory ¶
func NewProxyEngineConfigFactory(schema *Schema, proxyUpstreamConfig ProxyUpstreamConfig, batchFactory resolve.DataSourceBatchFactory, opts ...ProxyEngineConfigFactoryOption) *ProxyEngineConfigFactory
func (*ProxyEngineConfigFactory) EngineV2Configuration ¶
func (p *ProxyEngineConfigFactory) EngineV2Configuration() (EngineV2Configuration, error)
type ProxyEngineConfigFactoryOption ¶
type ProxyEngineConfigFactoryOption func(options *proxyEngineConfigFactoryOptions)
func WithProxyHttpClient ¶
func WithProxyHttpClient(client *http.Client) ProxyEngineConfigFactoryOption
type ProxyUpstreamConfig ¶
ProxyUpstreamConfig holds configuration to configure a single data source to a single upstream.
type Request ¶
type Request struct { OperationName string `json:"operationName"` Variables json.RawMessage `json:"variables"` Query string `json:"query"` // contains filtered or unexported fields }
func (*Request) CalculateComplexity ¶
func (r *Request) CalculateComplexity(complexityCalculator ComplexityCalculator, schema *Schema) (ComplexityResult, error)
func (*Request) IsIntrospectionQuery ¶
func (*Request) IsNormalized ¶
func (*Request) Normalize ¶
func (r *Request) Normalize(schema *Schema) (result NormalizationResult, err error)
func (*Request) OperationType ¶
func (r *Request) OperationType() (OperationType, error)
func (*Request) ValidateFieldRestrictions ¶
func (r *Request) ValidateFieldRestrictions(schema *Schema, restrictedFieldsList FieldRestrictionList, validator FieldRestrictionValidator) (RequestFieldsValidationResult, error)
ValidateFieldRestrictions will validate a request by using a list of allowed or blocked fields.
func (*Request) ValidateForSchema ¶
func (r *Request) ValidateForSchema(schema *Schema) (result ValidationResult, err error)
func (*Request) ValidateRestrictedFields
deprecated
func (r *Request) ValidateRestrictedFields(schema *Schema, restrictedFields []Type) (RequestFieldsValidationResult, error)
ValidateRestrictedFields validates a request by checking if `restrictedFields` contains blocked fields.
Deprecated: This function can only handle blocked fields. Use `ValidateFieldRestrictions` if you want to check for blocked or allowed fields instead.
type RequestError ¶
type RequestError struct { Message string `json:"message"` Locations []graphqlerrors.Location `json:"locations,omitempty"` Path ErrorPath `json:"path"` }
func (RequestError) Error ¶
func (o RequestError) Error() string
func (RequestError) MarshalJSON ¶
func (o RequestError) MarshalJSON() ([]byte, error)
type RequestErrors ¶
type RequestErrors []RequestError
func RequestErrorsFromError ¶
func RequestErrorsFromError(err error) RequestErrors
func RequestErrorsFromOperationReport ¶
func RequestErrorsFromOperationReport(report operationreport.Report) (errors RequestErrors)
func (RequestErrors) Count ¶
func (o RequestErrors) Count() int
func (RequestErrors) Error ¶
func (o RequestErrors) Error() string
func (RequestErrors) ErrorByIndex ¶
func (o RequestErrors) ErrorByIndex(i int) error
func (RequestErrors) WriteResponse ¶
func (o RequestErrors) WriteResponse(writer io.Writer) (n int, err error)
type RequestFields ¶
type RequestFields map[string]struct{}
type RequestFieldsValidator ¶
type RequestFieldsValidator interface {
Validate(request *Request, schema *Schema, restrictions []Type) (RequestFieldsValidationResult, error)
}
type RequestTypes ¶
type RequestTypes map[string]RequestFields
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
func NewSchemaFromString ¶
func (*Schema) GetAllFieldArguments ¶
func (s *Schema) GetAllFieldArguments(skipFieldFuncs ...SkipFieldFunc) []TypeFieldArguments
func (*Schema) GetAllNestedFieldChildrenFromTypeField ¶
func (s *Schema) GetAllNestedFieldChildrenFromTypeField(typeName string, fieldName string, skipFieldFuncs ...SkipFieldFunc) []TypeFields
func (*Schema) HasMutationType ¶
func (*Schema) HasQueryType ¶
HasQueryType TODO: should be deprecated?
func (*Schema) HasSubscriptionType ¶
func (*Schema) IntrospectionResponse ¶
IntrospectionResponse - writes full schema introspection response into writer
func (*Schema) IsNormalized ¶
func (*Schema) MutationTypeName ¶
func (*Schema) Normalize ¶
func (s *Schema) Normalize() (result NormalizationResult, err error)
func (*Schema) QueryTypeName ¶
func (*Schema) SubscriptionTypeName ¶
func (*Schema) Validate ¶
func (s *Schema) Validate() (result ValidationResult, err error)
type SchemaValidationError ¶
type SchemaValidationError struct {
Message string `json:"message"`
}
func (SchemaValidationError) Error ¶
func (s SchemaValidationError) Error() string
type SchemaValidationErrors ¶
type SchemaValidationErrors []SchemaValidationError
func (SchemaValidationErrors) Count ¶
func (s SchemaValidationErrors) Count() int
func (SchemaValidationErrors) Error ¶
func (s SchemaValidationErrors) Error() string
func (SchemaValidationErrors) ErrorByIndex ¶
func (s SchemaValidationErrors) ErrorByIndex(i int) error
func (SchemaValidationErrors) WriteResponse ¶
func (s SchemaValidationErrors) WriteResponse(writer io.Writer) (n int, err error)
type SkipFieldFunc ¶
func NewIsDataSourceConfigV2RootFieldSkipFunc ¶
func NewIsDataSourceConfigV2RootFieldSkipFunc(dataSources []plan.DataSourceConfiguration) SkipFieldFunc
func NewSkipReservedNamesFunc ¶
func NewSkipReservedNamesFunc() SkipFieldFunc
type TypeFieldArguments ¶
type TypeFieldLookupKey ¶
type TypeFieldLookupKey string
func CreateTypeFieldLookupKey ¶
func CreateTypeFieldLookupKey(typeName string, fieldName string) TypeFieldLookupKey
type TypeFields ¶
type ValidationResult ¶
func ValidateSchemaString ¶
func ValidateSchemaString(schema string) (result ValidationResult, err error)
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
federationtesting
|
|
accounts/graph
This file will not be regenerated automatically.
|
This file will not be regenerated automatically. |
gateway/http
Package http handles GraphQL HTTP Requests including WebSocket Upgrades.
|
Package http handles GraphQL HTTP Requests including WebSocket Upgrades. |
products/graph
This file will not be regenerated automatically.
|
This file will not be regenerated automatically. |
reviews/graph
This file will not be regenerated automatically.
|
This file will not be regenerated automatically. |