graph

package
v0.0.0-...-47e11bc Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Int64 = graphql.NewScalar(graphql.ScalarConfig{
	Name:        "Int64",
	Description: "64 bit integer",
	Serialize: func(value interface{}) interface{} {
		switch value := value.(type) {
		case int64:
			return value
		case *int64:
			if value == nil {
				return nil
			}
			return *value
		default:
			return nil
		}
	},
	ParseValue: func(value interface{}) interface{} {
		switch value := value.(type) {
		case int64:
			return value
		case *int64:
			if value == nil {
				return nil
			}
			return *value
		default:
			return nil
		}
	},
	ParseLiteral: func(valueAST ast.Value) interface{} {
		switch valueAST := valueAST.(type) {
		case *ast.IntValue:
			v, err := strconv.ParseInt(valueAST.Value, 10, 64)
			if err != nil {
				return nil
			}
			return v
		default:
			return nil
		}
	},
})

Functions

func BuildGraph

func BuildGraph(obj interface{}) (graphql.Schema, map[string]*graphql.Object, error)

func ToMap

func ToMap(obj interface{}) map[string]interface{}

func WrapPlugin

func WrapPlugin(plugin interface{}, wrapper interface{}) error

Types

type Graph

type Graph struct {
	Schema graphql.Schema
	Types  map[string]*graphql.Object
	Root   interface{}

	StopWorker context.CancelFunc
	// contains filtered or unexported fields
}

func New

func New(obj interface{}, plugins Plugins) (*Graph, error)

func (*Graph) SetRoot

func (t *Graph) SetRoot(root interface{}) error

func (*Graph) StartWorker

func (t *Graph) StartWorker() error

type Plugin

type Plugin struct {
	Schema func(*Graph) error                  `plugin:""`
	Root   func(*Graph, interface{}) error     `plugin:""`
	Clean  func()                              `plugin:""`
	Worker func(context.Context, *Graph) error `plugin:""`
}

type Plugins

type Plugins []Plugin

func WrapPlugins

func WrapPlugins(plugins []interface{}) (Plugins, error)

func (*Plugins) Clean

func (p *Plugins) Clean()

func (*Plugins) Root

func (p *Plugins) Root(t *Graph, root interface{}) error

func (*Plugins) Schema

func (p *Plugins) Schema(g *Graph) error

func (*Plugins) Worker

func (p *Plugins) Worker(ctx context.Context, cancel context.CancelFunc, t *Graph) error

Jump to

Keyboard shortcuts

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