gql

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

README

Comparing the old and new methods, we find that using slice makes the parsing 20% faster on average than using channels. Also, using slices allows the parser to backtrack and peek the tokens which couldn't be done using channels as each token can only be consumed once.

Name                              unit    Old     New     Improvement
----------------------------------------------------------------------
Benchmark_Filters-4               ns/op   14007   9634    31 %
Benchmark_Geq-4                   ns/op   11701   8602    26 %
Benchmark_Date-4                  ns/op   11687   8630    26 %
Benchmark_directors-4             ns/op   18663   14201   23 %
Benchmark_Filters_parallel-4      ns/op   6486    5015    22 %
Benchmark_Movies-4                ns/op   16097   12807   20 %
Benchmark_directors_parallel-4    ns/op   8766    6966    20 %
Benchmark_Mutation-4              ns/op   5167    4155    19 %
Benchmark_Movies_parallel-4       ns/op   7537    6151    18 %
Benchmark_Date_parallel-4         ns/op   5462    4515    17 %
Benchmark_Geq_parallel-4          ns/op   5390    4485    16 %
Benchmark_Mutation_parallel-4     ns/op   2326    2161    07 %
Benchmark_Mutation1000-4          ns/op   549428  512851  06 %
Benchmark_Mutation1000_parallel-4 ns/op   261785  254911  02 %

Documentation

Overview

Package gql is responsible for lexing and parsing a GraphQL query/mutation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Facets added in v0.7.3

type Facets struct {
	AllKeys bool
	Keys    []string // should be in sorted order.
}

Facet holds the information about gql Facets (edge key-value pairs).

type FilterTree added in v0.7.0

type FilterTree struct {
	Op    string
	Child []*FilterTree
	Func  *Function
}

FilterTree is the result of parsing the filter directive. Either you can have `Op and Children` on non-leaf nodes Or Func at leaf nodes.

type Function added in v0.7.0

type Function struct {
	Attr     string
	Name     string   // Specifies the name of the function.
	Args     []string // Contains the arguments of the function.
	NeedsVar []string // If the function requires some variable
}

Function holds the information about gql functions.

func (*Function) IsAggregator added in v0.7.3

func (f *Function) IsAggregator() bool

func (*Function) IsPasswordVerifier added in v0.7.3

func (f *Function) IsPasswordVerifier() bool

type GraphQuery

type GraphQuery struct {
	UID      []uint64
	Attr     string
	Langs    []string
	Alias    string
	IsCount  bool
	Var      string
	NeedsVar []string
	Func     *Function

	Args         map[string]string
	Children     []*GraphQuery
	Filter       *FilterTree
	Normalize    bool
	Facets       *Facets
	FacetsFilter *FilterTree
	// contains filtered or unexported fields
}

GraphQuery stores the parsed Query in a tree format. This gets converted to internally used query.SubGraph before processing the query.

func (*GraphQuery) DebugPrint added in v0.7.0

func (gq *GraphQuery) DebugPrint(prefix string)

DebugPrint is useful for debugging.

type Mutation

type Mutation struct {
	Set string
	Del string
}

Mutation stores the strings corresponding to set and delete operations.

type Result added in v0.7.2

type Result struct {
	Query     []*GraphQuery
	QueryVars []*Vars
	Mutation  *Mutation
}

Result struct contains the Query list, its corresponding variable use list and the mutation block.

func Parse

func Parse(input string) (res Result, rerr error)

Parse initializes and runs the lexer. It also constructs the GraphQuery subgraph from the lexed items.

type Vars added in v0.7.2

type Vars struct {
	Defines []string
	Needs   []string
}

Vars struct contains the list of variables defined and used by a query block.

Jump to

Keyboard shortcuts

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