utils

package
v0.0.0-...-7b4e26c Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2019 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Validator = validator.New()

Validator instance

Functions

func FromGlobalID

func FromGlobalID(globalID string) *relay.ResolvedGlobalID

FromGlobalID takes the "global ID" created by toGlobalID, and returns the type name and ID used to create it.

func GetUserFromCookie

func GetUserFromCookie(c Context) (*models.User, error)

GetUserFromCookie get user from cookie

func GlobalIDField

func GlobalIDField(name string) *graphql.Field

GlobalIDField short uuid

func GraphqlHandler

func GraphqlHandler(config handler.Config, w http.ResponseWriter, r *http.Request)

GraphqlHandler create graphql handler

func HandlerFunc

HandlerFunc http HandlerFun

func NewContext

func NewContext(c Context) context.Context

NewContext create new context

func NewHandler

NewHandler create graphql handler from APIGatewayProxyRequest

func RemoveToken

func RemoveToken(c Context)

RemoveToken unset token from cookie

func ResolveConnection

func ResolveConnection(p graphql.ResolveParams,
	c Context,
	resolve func(mods []qm.QueryMod) ([]interface{}, error),
	toSQLFields func(fields map[string]bool) qm.QueryMod,
	orderAsc bool) (interface{}, error)

ResolveConnection resolve connection

func SetToken

func SetToken(c Context, u *models.User) (token string, err error)

SetToken set cookie token

Types

type Context

type Context struct {
	Request  *http.Request
	Response http.ResponseWriter
	User     *models.User
	Params   map[string]string
	Host     string
	Binder   binding.Binding
}

Context graphql context

func FromContext

func FromContext(c context.Context) Context

FromContext convert context.Context to Context

func (*Context) Bind

func (c *Context) Bind(s interface{}, cb func(err validator.FieldError) string) (events.APIGatewayProxyResponse, error)

Bind struct

func (*Context) EnsureIsAuthorized

func (c *Context) EnsureIsAuthorized(cb func(*models.User) bool)

EnsureIsAuthorized user is authorized

func (*Context) JSON

func (c *Context) JSON(code int, v interface{}) (events.APIGatewayProxyResponse, error)

JSON APIGatewayProxyResponse

func (*Context) Panic

func (c *Context) Panic(code int, message string)

Panic error

func (*Context) Param

func (c *Context) Param(key string) string

Param get route param by key

func (*Context) Redirect

func (c *Context) Redirect(code int, url string) (events.APIGatewayProxyResponse, error)

Redirect redirect to url

func (*Context) Validate

func (c *Context) Validate(inputMap map[string]interface{}, s interface{}, cb func(err validator.FieldError) string)

Validate struct

type Cursor

type Cursor struct {
	ID        string
	CreatedAt string
}

Cursor used for node cursor

Jump to

Keyboard shortcuts

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