Documentation
¶
Index ¶
- Constants
- func SplitFieldsQ(inline string) []string
- type Args
- func (vs Args) Clone() Args
- func (vs Args) Get(param string) any
- func (vs Args) Has(param string) (ok bool)
- func (vs Args) Page() uint32
- func (vs *Args) Set(param string, value any) error
- func (vs Args) Size() int32
- func (vs Args) Sort() []string
- func (vs Args) ValueOf(param string, typeOf Input) (value any, err error)
- type Argument
- type Bool
- type FieldEncoding
- type FieldExpansion
- type FieldsQ
- func (vs *FieldsQ) Add(out Query) bool
- func (vs FieldsQ) Clone() FieldsQ
- func (fs FieldsQ) Encode(syntax ...FieldEncoding) (text []byte, err error)
- func (req FieldsQ) Fields() []string
- func (vs FieldsQ) Get(name string) *Query
- func (vs FieldsQ) Has(name string) bool
- func (req FieldsQ) Index(name string) int
- func (fs FieldsQ) MarshalText() ([]byte, error)
- func (fs *FieldsQ) Parse(s string, decode ...FieldEncoding) error
- func (fs *FieldsQ) ParseQuery(vs []string, decode ...FieldEncoding) error
- func (fs FieldsQ) String() string
- type Input
- type InputArgs
- type InputPage
- type InputSize
- type InputSort
- type Metadata
- type NotNull
- type OutputFunc
- type Query
- type ResolveArgs
- type String
Constants ¶
const ( DOT = '.' COMMA = ',' PLUS = '+' HYPHEN = '-' EXCLAM = '!' USCORE = '_' LPAREN = '(' SQUOTE = '\'' DQUOTE = '"' RPAREN = ')' LCURLY = '{' RCURLY = '}' ESCAPE = '\\' ASTERISK = '*' )
Variables ¶
This section is empty.
Functions ¶
func SplitFieldsQ ¶
InlineFieldsQ split given values into set of Field(s)Q selection.
Types ¶
type Argument ¶
type Argument struct { // Name of the Argument Name string `json:"name"` // Type of the Argument Type Input `json:"typeOf"` // OPTIONAL. Default Value Value any `json:"value,omitempty"` }
Input Argument descriptor
type FieldEncoding ¶
type FieldEncoding func(syntax *FieldExpansion)
FieldEncoding as an expansion option
func DefaultFields ¶
func DefaultFields(q ...string) FieldEncoding
DefaultFields FieldEncoding Option. If no ?fields= were specified, this set of `q` will be used.
func NoArgs ¶
func NoArgs() FieldEncoding
NoArgs FieldEncoding Option. Disallow field[.arg(input)]* component(s)
func NoNested ¶
func NoNested() FieldEncoding
NoQuery FieldEncoding Option. Does NOT expose .query(),.. component(s)
func Sorting ¶
func Sorting() FieldEncoding
Sorting FieldEncoding Option. Cause to validate ?sort= fields spec
type FieldExpansion ¶
type FieldExpansion struct { // Invalidate field.query(args) expansion NoArgs bool // Invalidate field{nested,..} expansion NoNested bool // Default fields set if none specified // Used to reassign Metadata.Default set. Default []string // Sorting fields specification mode ? // // sort ::= spec *( "," spec ) // spec ::= [ ORDER ] name / nest // nest ::= name "{" nest / sort "}" // name ::= ALPHA / DIGIT / USCORE ; field name // // ALPHA = %x41-5A / %x61-7A ; "A"-"Z" / "a"-"z" // DIGIT = %x30-39 ; "0"-"9" // USCORE = %x5F ; underscore ; "_" // // Examples: // // ?sort=+id,names{!common_name,id} // ?sort=id&sort=names{-common_name,id}; affected as above // // Invalid: // ?sort=+id,!names{-common_name,id}; illegal "!"; (nested only) fields MAY be sorted // // If false - regular GET fields specification mode is used. Sorting bool }
FieldExpansion syntax options.
func NewFieldExpansion ¶
func NewFieldExpansion(options ...FieldEncoding) (syntax FieldExpansion)
type FieldsQ ¶
type FieldsQ []*Query
Fields[Q]uery represents a set of query{ fields }.
func ParseFields ¶
func ParseFields(s string, decode ...FieldEncoding) (fields FieldsQ, err error)
ParseFields decodes ?fields=name[.query([args..]),..][{nested,..}][,..] string specification.
func ParseFieldsQuery ¶
func ParseFieldsQuery(vs []string, decode ...FieldEncoding) (fields FieldsQ, err error)
ParseFieldsQuery acts like ParseFields method, but decodes ?fields=[&fields=] query specification.
func (FieldsQ) MarshalText ¶
func (*FieldsQ) ParseQuery ¶
func (fs *FieldsQ) ParseQuery(vs []string, decode ...FieldEncoding) error
type Input ¶
type Input interface { // String type name GoString() string // Decode input data source value InputValue(src any) (any, error) }
Input Type interface
type InputArgs ¶
InputArgs maps argument name to it's input type
type InputSize ¶
type InputSize struct {
Minimum, Maximum, Default int32
}
Input type of the list (size:int32)
type Metadata ¶
type Metadata struct { // Name of the Object Name string `json:"name"` // Type of the Output data Type string `json:"typeOf"` // OPTIONAL. Input Arguments supported Args InputArgs `json:"input,omitempty"` // OPTIONAL. Output Fields of the Object Type Fields []*Metadata `json:"fields,omitempty"` // OPTIONAL. Default set of output Fields; expansion of ('*') Default []string `json:"output,omitempty"` // Resolve Output data or an error. Resolve OutputFunc `json:"-"` }
GraphQL Metadata about an Object.
func (*Metadata) FieldQ ¶
func (md *Metadata) FieldQ(req *Query, syntax ...FieldEncoding) error
GetQuery validates and normalize given `req` FieldQ of this Metadata configuration.
func (*Metadata) FieldsQ ¶
func (md *Metadata) FieldsQ(req *FieldsQ, syntax ...FieldEncoding) error
FieldsQ presets ( validate & normalize & defaults ) given FieldsQ `req` according to this `md` Metadata.Fields and optional `syntax` options configuration.
func (*Metadata) ParseFields ¶
func (md *Metadata) ParseFields(vs []string, decode ...FieldEncoding) (fields FieldsQ, err error)
ParseFields decodes ?fields=[&fields=] query value(s) spec. Validate & normalize expansion due to `md`.Fields configuration.
type OutputFunc ¶
type OutputFunc func(output *ResolveArgs) (data any, err error)
OutputFunc must resolve Node-* related data for output
type Query ¶
type Query struct { // REQUIRED. Name of the Query Object for output. Name string // OPTIONAL. Input arguments of the Query. Args // OPTIONAL. Nested Fields of the Query Object. Fields FieldsQ }
Field[Q]uery