scalars

package
v0.0.0-...-a34b4de Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2018 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeExecutableSchema

func MakeExecutableSchema(resolvers Resolvers) graphql.ExecutableSchema

func MarshalID

func MarshalID(id external.ObjectID) graphql.Marshaler

Lets redefine the base ID type to use an id from an external library

func MarshalTimestamp

func MarshalTimestamp(t time.Time) graphql.Marshaler

if the type referenced in types.json is a function that returns a marshaller we can use it to encode and decode onto any existing go type.

func UnmarshalID

func UnmarshalID(v interface{}) (external.ObjectID, error)

And the same for the unmarshaler

func UnmarshalTimestamp

func UnmarshalTimestamp(v interface{}) (time.Time, error)

Unmarshal{Typename} is only required if the scalar appears as an input. The raw values have already been decoded from json into int/float64/bool/nil/map[string]interface/[]interface

Types

type Address

type Address struct {
	ID       external.ObjectID `json:"id"`
	Location *Point            `json:"location"`
}

type Banned

type Banned bool

type Point

type Point struct {
	X int
	Y int
}

Point is serialized as a simple array, eg [1, 2]

func (Point) MarshalGQL

func (p Point) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface

func (*Point) UnmarshalGQL

func (p *Point) UnmarshalGQL(v interface{}) error

type Resolver

type Resolver struct {
}
func (r *Resolver) Query_search(ctx context.Context, input SearchArgs) ([]User, error)

func (*Resolver) Query_user

func (r *Resolver) Query_user(ctx context.Context, id external.ObjectID) (*User, error)

func (*Resolver) User_customResolver

func (r *Resolver) User_customResolver(ctx context.Context, obj *User) (Point, error)

func (*Resolver) User_primitiveResolver

func (r *Resolver) User_primitiveResolver(ctx context.Context, obj *User) (string, error)

type Resolvers

type Resolvers interface {
	Query_user(ctx context.Context, id external.ObjectID) (*User, error)
	Query_search(ctx context.Context, input SearchArgs) ([]User, error)

	User_primitiveResolver(ctx context.Context, obj *User) (string, error)
	User_customResolver(ctx context.Context, obj *User) (Point, error)
}

type SearchArgs

type SearchArgs struct {
	Location     *Point
	CreatedAfter *time.Time
	IsBanned     Banned
}

func UnmarshalSearchArgs

func UnmarshalSearchArgs(v interface{}) (SearchArgs, error)

type Tier

type Tier uint

A custom enum that uses integers to represent the values in memory but serialize as string for graphql

const (
	TierA Tier = iota
	TierB Tier = iota
	TierC Tier = iota
)

func TierForStr

func TierForStr(str string) (Tier, error)

func (Tier) IsValid

func (e Tier) IsValid() bool

func (Tier) MarshalGQL

func (e Tier) MarshalGQL(w io.Writer)

func (Tier) String

func (e Tier) String() string

func (*Tier) UnmarshalGQL

func (e *Tier) UnmarshalGQL(v interface{}) error

type User

type User struct {
	ID       external.ObjectID
	Name     string
	Created  time.Time // direct binding to builtin types with external Marshal/Unmarshal methods
	IsBanned Banned    // aliased primitive
	Address  Address
	Tier     Tier
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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