gqlgen: github.com/99designs/gqlgen/example/scalars/model Index | Files

package model

import "github.com/99designs/gqlgen/example/scalars/model"

Index

Package Files

generated.go model.go

func MarshalID Uses

func MarshalID(id external.ObjectID) graphql.Marshaler

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

func MarshalTimestamp Uses

func MarshalTimestamp(t time.Time) graphql.Marshaler

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

func UnmarshalID Uses

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

And the same for the unmarshaler

func UnmarshalTimestamp Uses

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

type Address Uses

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

type Banned Uses

type Banned bool

func (Banned) MarshalGQL Uses

func (b Banned) MarshalGQL(w io.Writer)

func (*Banned) UnmarshalGQL Uses

func (b *Banned) UnmarshalGQL(v interface{}) error

type Point Uses

type Point struct {
    X   int
    Y   int
}

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

func (Point) MarshalGQL Uses

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

MarshalGQL implements the graphql.Marshaler interface

func (*Point) UnmarshalGQL Uses

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

type SearchArgs Uses

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

type Tier Uses

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 Uses

func TierForStr(str string) (Tier, error)

func (Tier) IsValid Uses

func (e Tier) IsValid() bool

func (Tier) MarshalGQL Uses

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

func (Tier) String Uses

func (e Tier) String() string

func (*Tier) UnmarshalGQL Uses

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

type User Uses

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

Package model imports 8 packages (graph) and is imported by 2 packages. Updated 2019-03-25. Refresh now. Tools for package owners.