gql

package
v0.0.0-...-556ca06 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OneToOne  Assoc  = "1-to-1"
	Proof     string = "proof"
	Uid       string = "uid"
	Has       string = "has"
	CreatedAt string = "createdAt"
	LT        string = "lt"
	LE        string = "le"
	GT        string = "gt"
	GE        string = "ge"
	TypeFn    string = "type"
)

Variables

This section is empty.

Functions

func EncodeGraphQueries

func EncodeGraphQueries(source []GraphQuery) []*gql.GraphQuery

func EncodeGraphQuery

func EncodeGraphQuery(source GraphQuery) *gql.GraphQuery

Types

type Arg

type Arg struct {
	Value        string `yaml:"value,omitempty" json:"value,omitempty"`
	IsValueVar   bool   `yaml:"isValueVar,omitempty" json:"isValueVar,omitempty"` // If argument is val(a)
	IsGraphQLVar bool   `yaml:"isGraphQLVar,omitempty" json:"isGraphQLVar,omitempty"`
}

type Assoc

type Assoc string

type Computed

type Computed struct {
	Name       string                 `yaml:"name,omitempty" json:"name,omitempty"`
	Attributes map[string]interface{} `yaml:"attributes,omitempty" json:"attributes,omitempty"`
}

type FacetParam

type FacetParam struct {
	Key   string `yaml:"key,omitempty" json:"key,omitempty"`
	Alias string `yaml:"alias,omitempty" json:"alias,omitempty"`
}

type FacetParams

type FacetParams struct {
	AllKeys bool         `yaml:"allKeys,omitempty" json:"allKeys,omitempty"`
	Param   []FacetParam `yaml:"param,omitempty" json:"param,omitempty"`
}

type FilterTree

type FilterTree struct {
	Op    Operator     `yaml:"op,omitempty" json:"op,omitempty"`
	Child []FilterTree `yaml:"child,omitempty" json:"child,omitempty"`
	Func  *Function    `yaml:"func,omitempty" json:"func,omitempty"`
}

type Function

type Function struct {
	Attr       string       `yaml:"attr,omitempty" json:"attr,omitempty"`
	Lang       string       `yaml:"lang,omitempty" json:"lang,omitempty"` // language of the attribute value
	Name       string       `yaml:"name,omitempty" json:"name,omitempty"` // Specifies the name of the function.
	Args       []Arg        `yaml:"args,omitempty" json:"args,omitempty"` // Contains the arguments of the function.
	UID        []uint64     `yaml:"uid,omitempty" json:"uid,omitempty"`
	NeedsVar   []VarContext `yaml:"needsVar,omitempty" json:"needsVar,omitempty"`     // If the function requires some variable
	IsCount    bool         `yaml:"isCount,omitempty" json:"isCount,omitempty"`       // gt(count(friends),0)
	IsValueVar bool         `yaml:"isValueVar,omitempty" json:"isValueVar,omitempty"` // eq(val(s), 5)
}

type GraphQuery

type GraphQuery struct {
	UID        []uint64     `yaml:"uid,omitempty" json:"uid,omitempty"`
	Attr       string       `yaml:"attr,omitempty" json:"attr,omitempty"`
	Langs      []string     `yaml:"langs,omitempty" json:"langs,omitempty"`
	Alias      string       `yaml:"alias,omitempty" json:"alias,omitempty"`
	Model      string       `yaml:"model,omitempty" json:"model,omitempty"`
	Default    interface{}  `yaml:"default,omitempty" json:"default,omitempty"`
	Assoc      Assoc        `yaml:"assoc,omitempty" json:"assoc,omitempty"`
	IsCount    bool         `yaml:"isCount,omitempty" json:"isCount,omitempty"`
	Computed   *Computed    `yaml:"computed,omitempty" json:"computed,omitempty"`
	IsInternal bool         `yaml:"isInternal,omitempty" json:"isInternal,omitempty"`
	IsGroupby  bool         `yaml:"isGroupby,omitempty" json:"isGroupby,omitempty"`
	Var        string       `yaml:"var,omitempty" json:"var,omitempty"`
	NeedsVar   []VarContext `yaml:"needsVar,omitempty" json:"needsVar,omitempty"`
	Func       *Function    `yaml:"func,omitempty" json:"func,omitempty"`
	Expand     string       `yaml:"expand,omitempty" json:"expand,omitempty"` // Which variable to expand with.

	Args map[string]string `yaml:"args,omitempty" json:"args,omitempty"`
	// Query can have multiple sort parameters.
	Order            []Order           `yaml:"order,omitempty" json:"order,omitempty"`
	Children         []GraphQuery      `yaml:"children,omitempty" json:"children,omitempty"`
	Recurse          bool              `yaml:"recurse,omitempty" json:"recurse,omitempty"`
	RecurseArgs      *RecurseArgs      `yaml:"recurseArgs,omitempty" json:"recurseArgs,omitempty"`
	ShortestPathArgs *ShortestPathArgs `yaml:"shortestPathArgs,omitempty" json:"shortestPathArgs,omitempty"`
	Filter           *FilterTree       `yaml:"filter,omitempty" json:"filter,omitempty"`
	MathExp          *MathTree         `yaml:"mathExp,omitempty" json:"mathExp,omitempty"`
	Normalize        bool              `yaml:"normalize,omitempty" json:"normalize,omitempty"`
	Facets           *FacetParams      `yaml:"facets,omitempty" json:"facets,omitempty"`
	FacetsFilter     *FilterTree       `yaml:"facetsFilter,omitempty" json:"facetsFilter,omitempty"`
	GroupbyAttrs     []GroupByAttr     `yaml:"groupbyAttrs,omitempty" json:"groupbyAttrs,omitempty"`
	FacetVar         map[string]string `yaml:"facetVar,omitempty" json:"facetVar,omitempty"`
	FacetOrder       string            `yaml:"facetOrder,omitempty" json:"facetOrder,omitempty"`
	FacetDesc        bool              `yaml:"facetDesc,omitempty" json:"facetDesc,omitempty"`
}

func CopyGraphQueries

func CopyGraphQueries(source []GraphQuery) []GraphQuery

func CopyGraphQuery

func CopyGraphQuery(source GraphQuery) GraphQuery

func DecodeGraphQueries

func DecodeGraphQueries(source []*gql.GraphQuery) []GraphQuery

func DecodeGraphQuery

func DecodeGraphQuery(source *gql.GraphQuery) GraphQuery

func Recurse

func Recurse(root GraphQuery, attribute string, depth int) GraphQuery

type GroupByAttr

type GroupByAttr struct {
	Attr  string   `yaml:"attr,omitempty" json:"attr,omitempty"`
	Alias string   `yaml:"alias,omitempty" json:"alias,omitempty"`
	Langs []string `yaml:"langs,omitempty" json:"langs,omitempty"`
}

type MathTree

type MathTree struct {
	Fn    string         `yaml:"fn,omitempty" json:"fn,omitempty"`
	Var   string         `yaml:"var,omitempty" json:"var,omitempty"`
	Const Val            `yaml:"const,omitempty" json:"const,omitempty"` // This will always be parsed as a float value
	Val   map[uint64]Val `yaml:"val,omitempty" json:"val,omitempty"`
	Child []MathTree     `yaml:"child,omitempty" json:"child,omitempty"`
}

type Operator

type Operator string
const (
	Not Operator = "not"
	EQ  Operator = "eq"
	And Operator = "and"
	Or  Operator = "or"
)

type Order

type Order struct {
	Attr  string   `yaml:"attr,omitempty" json:"attr,omitempty"`
	Desc  bool     `yaml:"desc,omitempty" json:"desc,omitempty"`
	Langs []string `yaml:"langs,omitempty" json:"langs,omitempty"`
}

type RecurseArgs

type RecurseArgs struct {
	Depth     uint64 `yaml:"depth,omitempty" json:"depth,omitempty"`
	AllowLoop bool   `yaml:"allowLoop,omitempty" json:"allowLoop,omitempty"`
}

type ShortestPathArgs

type ShortestPathArgs struct {
	// From, To can have a uid or a uid function as the argument.
	// 1. from: 0x01
	// 2. from: uid(0x01)
	// 3. from: uid(p) // a variable
	From *Function `json:"from,omitempty"`
	To   *Function `json:"to,omitempty"`
}

type TypeID

type TypeID int32

type Val

type Val struct {
	Tid   TypeID      `yaml:"tid,omitempty" json:"tid,omitempty"`
	Value interface{} `yaml:"value,omitempty" json:"value,omitempty"`
}

type VarContext

type VarContext struct {
	Name string `yaml:"name,omitempty" json:"name,omitempty"`
	Typ  int    `yaml:"typ,omitempty" json:"typ,omitempty"` //  1 for UID vars, 2 for value vars
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL