Documentation ¶
Index ¶
- Constants
- func AddRelationFilters(ctx context.Context, s *ast.Schema, obj interface{}) context.Context
- func GenerateTableName(n int) string
- func GetFilterInput(s *ast.Schema, f *ast.Definition) *ast.Definition
- func WithFieldFilterContext(ctx context.Context, rc *FilterFieldContext) context.Context
- type AggregateBuilder
- type AggregatorOperator
- type Builder
- type ColumnCaseConverter
- type Config
- type DialectDirective
- type Field
- func CollectFields(ctx context.Context, schema *ast.Schema) Field
- func CollectFromQuery(field *ast.Field, schema *ast.Schema, opCtx *graphql.OperationContext, ...) Field
- func GetAggregateField(parentField, aggField Field) Field
- func NewField(parent *Field, field *ast.Field, schema *ast.Schema, ...) Field
- type Fields
- type FilterContext
- type FilterFieldContext
- type LogicalOperator
- type MutationBuilder
- type OperationType
- type Operator
- type OrderField
- type OrderingTypes
- type QueryBuilder
- type TableNameGenerator
Constants ¶
const ( TypeScalar fieldType = "Scalar" TypeRelation fieldType = "Relation" TypeAggregate fieldType = "Aggregate" TypeObject fieldType = "Object" )
Variables ¶
This section is empty.
Functions ¶
func AddRelationFilters ¶
func GenerateTableName ¶
func GetFilterInput ¶
func GetFilterInput(s *ast.Schema, f *ast.Definition) *ast.Definition
func WithFieldFilterContext ¶
func WithFieldFilterContext(ctx context.Context, rc *FilterFieldContext) context.Context
Types ¶
type AggregateBuilder ¶
AggregateBuilder allows Builders to build aggregate queries on _XYZAggregate fields
type AggregatorOperator ¶
type AggregatorOperator func(table exp.AliasedExpression, fields []Field) (goqu.Expression, error)
AggregatorOperator gets called on aggregation methods // TBD //
type Builder ¶
type Builder interface { QueryBuilder AggregateBuilder MutationBuilder }
type ColumnCaseConverter ¶
ColumnCaseConverter converts columns from ast.Field Name to database field name, by default it converts to snake case but sometimes as a user you want to override this logic / define special abbreviations etc'
type Config ¶
type Config struct { Schema *ast.Schema Logger log.Logger // CustomOperators are user defined operators, can also be used to override existing default operators. CustomOperators map[string]Operator // TableNameGenerator allows defining how aliases "Table" names are generated in the query, this is mostly used for test TableNameGenerator TableNameGenerator // ColumnCaseConverter converts columns from ast.Field Name to database field name, by default it converts to snake case // but sometimes as a user you want to override this logic / define special abbreviations etc' ColumnCaseConverter ColumnCaseConverter }
Config is the basic level of data passed to a builder when it's created
type DialectDirective ¶
func GetDialectDirective ¶
func GetDialectDirective(schema *ast.Schema, field Field) (*DialectDirective, error)
type Field ¶
type Field struct { // Original *ast.Field *ast.Field // Field sub selection, if field type is TypeScalar, selections will be empty Selections Fields // FieldType i.e Scalar/Relation/Aggregate/Object etc' FieldType fieldType // Arguments passed to this field if any. Arguments map[string]interface{} // TypeDefinition is the ast.Schema Type, this is saved for easier access TypeDefinition *ast.Definition // Parent field of this field Parent *Field }
Field is a helpful wrapper over *ast.Field adding more custom information when collecting the GraphQL query AST
func CollectFromQuery ¶
func GetAggregateField ¶
func (Field) GetTypeName ¶
func (Field) Relation ¶
func (f Field) Relation() *schema.RelationDirective
Relation directive on field, if it exists
func (Field) Table ¶
func (f Field) Table() *schema.TableDirective
Table directive on field, if it exists
type FilterContext ¶
type FilterContext string
type FilterFieldContext ¶
type FilterFieldContext struct {
Filters map[string]interface{}
}
func GetFieldFilterContext ¶
func GetFieldFilterContext(ctx context.Context) *FilterFieldContext
type LogicalOperator ¶
type LogicalOperator string
const ( LogicalOperatorAND LogicalOperator = "AND" LogicalOperatorOR LogicalOperator = "OR" LogicalOperatorNot LogicalOperator = "NOT" )
type MutationBuilder ¶
type MutationBuilder interface { Create(field Field) (string, []interface{}, error) Delete(field Field) (string, []interface{}, error) }
MutationBuilder supports building DELETE/CREATE/UPDATE queries from given GraphQL
type OperationType ¶
type OperationType string
const ( QueryOperation OperationType = "query" InsertOperation OperationType = "insert" DeleteOperation OperationType = "delete" UpdateOperation OperationType = "update" UnknownOperation OperationType = "unknown" )
func GetOperationType ¶
func GetOperationType(ctx context.Context) OperationType
type Operator ¶
type Operator func(table exp.AliasedExpression, key string, value interface{}) goqu.Expression
Operator gets called on filters expressions written in graphql. Users can define new operators in the graphql schema, and define operator functions for those operators based on the operator name given. Operators are added by "key" to comparator Input types, and get called with expected value.
type OrderField ¶
type OrderField struct { Key string Type OrderingTypes }
func CollectOrdering ¶
func CollectOrdering(ordering interface{}) ([]OrderField, error)
type OrderingTypes ¶
type OrderingTypes string
const ( InputFieldName = "inputs" OrderingTypesAsc OrderingTypes = "ASC" OrderingTypesDesc OrderingTypes = "DESC" OrderingTypesAscNull OrderingTypes = "ASC_NULL_FIRST" OrderingTypesDescNull OrderingTypes = "DESC_NULL_FIRST" )
type QueryBuilder ¶
QueryBuilder supports building a full query from a given GraphQL query