gql

package module
v0.0.0-...-524d0fb Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2021 License: MIT Imports: 14 Imported by: 0

README

go-gql

A GraphQL library designed with specific opinionated properties in mind

Documentation

Overview

Package gql provides a GraphQL client implementation for Golang.

For more information, see package github.com/machship-oss/go-gql

Status: In active early research and development.

For now, see README for more details.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrArgumentCouldNotBeEncodedAsJSON    = errors.New("argument could not be encoded as JSON")
	ErrArgumentError                      = errors.New("unkown argument error")
	ErrArgumentsCannotBeEmpty             = errors.New("arguments cannot be empty")
	ErrArgumentWasNotASliceOrArray        = errors.New("argument was not a slice or array")
	ErrArgumentWasNotAStruct              = errors.New("argument was not a struct")
	ErrJSONTagMissingOrNoValue            = errors.New("json tag was missing or did not have a value")
	ErrNoIsResultTagFoundInFieldsOfStruct = errors.New("no isResult tag found in fields of struct")
	ErrOperationCouldNotBeGenerated       = errors.New("operation could not be generated")
	ErrResultTypeNotHandled               = errors.New("result type not handled")
	ErrResultWasNotASliceOrArray          = errors.New("result was not a slice or array")
	ErrResultWasNotPointer                = errors.New("result was not pointer")
	ErrResultWasNotPointerToStruct        = errors.New("result was not pointer to struct")
)

Functions

This section is empty.

Types

type AddBaseInput

type AddBaseInput struct {
	DateCreated *Time `json:"dateCreated,omitempty"`
}

type AddOp

type AddOp struct {
	ResultObject IMutationResult
	Arguments    IIsAdd
	// contains filtered or unexported fields
}

type AggregateArguments

type AggregateArguments struct {
	Filter IFilter
}

type AggregateOp

type AggregateOp struct {
	ResultObject IAggregateResult
	Arguments    *AggregateArguments
	// contains filtered or unexported fields
}

type Base

type Base struct {
	ID             *ID   `json:"id,omitempty"`
	DateCreatedUTC *Time `json:"dateCreatedUTC,omitempty"`

	//TypeName is readonly and can only be queried from the server
	TypeName *String `json:"__typename,omitempty"`
}

type BaseAggregate

type BaseAggregate struct {
	Count int `json:"count,omitempty"`
}

type BaseFields

type BaseFields struct {
}

type BaseFilter

type BaseFilter struct {
	ID          *ID             `json:"id,omitempty"`
	DateCreated *DateTimeFilter `json:"dateCreated,omitempty"`
}

type BaseGet

type BaseGet struct {
	ID             *ID   `json:"id,omitempty"`
	DateCreatedUTC *Time `json:"dateCreatedUTC,omitempty"`
}

type BaseHasChoice

type BaseHasChoice string
const (
	HC_BaseDateCreated BaseHasChoice = "dateCreated"
)

func (*BaseHasChoice) GetName

func (c *BaseHasChoice) GetName() string

type BaseOrderChoice

type BaseOrderChoice string
const (
	OC_BaseDateCreated BaseOrderChoice = "dateCreated"
)

func (*BaseOrderChoice) GetName

func (c *BaseOrderChoice) GetName() string

type BasePatch

type BasePatch struct {
	DateCreated *Time `json:"dateCreated,omitempty"`
}

type BaseRef

type BaseRef struct {
	ID *ID `json:"id,omitempty"`
}

type Bool

type Bool struct {
	Bool  bool
	Valid bool // Valid is true if Bool is not NULL
}

func NewBool

func NewBool(x bool) *Bool

func NewBoolStruct

func NewBoolStruct(x bool) Bool

func (Bool) GetName

func (nb Bool) GetName() string

func (Bool) MarshalJSON

func (nb Bool) MarshalJSON() ([]byte, error)

func (*Bool) UnmarshalJSON

func (nb *Bool) UnmarshalJSON(data []byte) error

type DateTimeFilter

type DateTimeFilter struct {
	Equal              *Time          `json:"eq,omitempty"`
	LessThanOrEqual    *Time          `json:"le"`
	LessThan           *Time          `json:"lt"`
	GreaterThanOrEqual *Time          `json:"ge"`
	GreaterThan        *Time          `json:"gt"`
	Between            *DateTimeRange `json:"between"`
}

type DateTimeRange

type DateTimeRange struct {
	Min *Time `json:"min"`
	Max *Time `json:"max"`
}

type DeleteOp

type DeleteOp struct {
	ResultObject IMutationResult
	Arguments    IIsDelete
	// contains filtered or unexported fields
}

type Float64

type Float64 struct {
	Float64 float64
	Valid   bool // Valid is true if Float64 is not NULL
}

func NewFloat64

func NewFloat64(x float64) *Float64

func NewFloat64Struct

func NewFloat64Struct(x float64) Float64

func (Float64) GetName

func (nb Float64) GetName() string

func (Float64) MarshalJSON

func (nf Float64) MarshalJSON() ([]byte, error)

func (*Float64) UnmarshalJSON

func (nf *Float64) UnmarshalJSON(data []byte) error

type GetOp

type GetOp struct {
	ResultObject ISingleResult
	Arguments    IIsGet
	// contains filtered or unexported fields
}

type GqlError

type GqlError struct {
	InnerError error
	// contains filtered or unexported fields
}

func (GqlError) String

func (e GqlError) String() string

type GraphQL

type GraphQL struct {
	// contains filtered or unexported fields
}

Client is a GraphQL client.

func NewGraphQL

func NewGraphQL(url string, httpClient *http.Client) *GraphQL

NewClient creates a GraphQL client targeting the specified GraphQL server URL. If httpClient is nil, then http.DefaultClient is used.

func (*GraphQL) Add

func (c *GraphQL) Add(ctx context.Context, op *AddOp) (err error)

func (*GraphQL) Aggregate

func (c *GraphQL) Aggregate(ctx context.Context, op *AggregateOp) (err error)

func (*GraphQL) BulkMutation

func (c *GraphQL) BulkMutation(ctx context.Context, cont *MutationContainer) (err error)

func (*GraphQL) BulkQuery

func (c *GraphQL) BulkQuery(ctx context.Context, cont *QueryContainer) (err error)

func (*GraphQL) Delete

func (c *GraphQL) Delete(ctx context.Context, op *DeleteOp) (err error)

func (*GraphQL) DoRaw

func (c *GraphQL) DoRaw(ctx context.Context, query string, vars map[string]interface{}, outputTypes map[string]interface{}) (err error)

func (*GraphQL) Get

func (c *GraphQL) Get(ctx context.Context, op *GetOp) (err error)

func (*GraphQL) Query

func (c *GraphQL) Query(ctx context.Context, op *QueryOp) (err error)

func (*GraphQL) Update

func (c *GraphQL) Update(ctx context.Context, op *UpdateOp) (err error)

type GraphqlErrors

type GraphqlErrors []struct {
	Message   string `json:"message"`
	Locations []struct {
		Line   int `json:"line,omitempty"`
		Column int `json:"column,omitempty"`
	} `json:"locations,omitempty"`
}

errors represents the "errors" array in a response from a GraphQL server. If returned via error interface, the slice is expected to contain at least 1 element.

Specification: https://facebook.github.io/graphql/#sec-Errors.

func (GraphqlErrors) Error

func (e GraphqlErrors) Error() string

Error implements error interface.

type IAggregateResult

type IAggregateResult interface {
	AggregateResultName() string
}

type ID

type ID struct {
	ID    string
	Valid bool // Valid is true if ID is not NULL
}

func NewID

func NewID(x string) *ID

func NewIDStruct

func NewIDStruct(x string) ID

func (ID) GetName

func (nb ID) GetName() string

func (ID) MarshalJSON

func (ns ID) MarshalJSON() ([]byte, error)

func (*ID) UnmarshalJSON

func (ns *ID) UnmarshalJSON(data []byte) error

type IFilter

type IFilter interface {
	IsFilter()
	IsArg()
	GetName() string
}

type IIsAdd

type IIsAdd interface {
	AddName() string
	IsArg()
}

type IIsArg

type IIsArg interface {
	IsArg()
}

type IIsDelete

type IIsDelete interface {
	DeleteName() string
	DeleteFilter() IFilter
	IsArg()
}

type IIsGet

type IIsGet interface {
	IsGet()
	IsArg()
}

type IIsUpdate

type IIsUpdate interface {
	IsUpdate()
	IsArg()
}

type IMultiResult

type IMultiResult interface {
	MultiResultName() string
}

type IMutationResult

type IMutationResult interface {
	MutationName() string
}

type IOrder

type IOrder interface {
	IsOrder()
	GetName() string
}

type ISingleResult

type ISingleResult interface {
	SingleResultName() string
}

type Int

type Int struct {
	Int   int
	Valid bool // Valid is true if Int is not NULL
}

func NewInt

func NewInt(x int) *Int

func NewIntStruct

func NewIntStruct(x int) Int

func (Int) GetName

func (nb Int) GetName() string

func (Int) MarshalJSON

func (ni Int) MarshalJSON() ([]byte, error)

func (*Int) UnmarshalJSON

func (ni *Int) UnmarshalJSON(data []byte) error

type Int64

type Int64 struct {
	Int64 int64
	Valid bool // Valid is true if Int64 is not NULL
}

func NewInt64

func NewInt64(x int64) *Int64

func NewInt64Struct

func NewInt64Struct(x int64) Int64

func (Int64) GetName

func (nb Int64) GetName() string

func (Int64) MarshalJSON

func (ni Int64) MarshalJSON() ([]byte, error)

func (*Int64) UnmarshalJSON

func (ni *Int64) UnmarshalJSON(data []byte) error

type MutationContainer

type MutationContainer struct {
	AddOps    []*AddOp
	UpdateOps []*UpdateOp
	DeleteOps []*DeleteOp
	// contains filtered or unexported fields
}

type Point

type Point struct {
	Latitude  *Float64 `json:"latitude,omitempty"`
	Longitude *Float64 `json:"longitude,omitempty"`
}

func NewPoint

func NewPoint(lat, lng float64) *Point

func NewPointStruct

func NewPointStruct(lat, lng float64) Point

func (Point) GetName

func (nb Point) GetName() string

type QueryArguments

type QueryArguments struct {
	Filter IFilter
	Order  IOrder
	First  *Int
	Offset *Int
}

type QueryContainer

type QueryContainer struct {
	QueryOps     []*QueryOp
	GetOps       []*GetOp
	AggregateOps []*AggregateOp
	// contains filtered or unexported fields
}

type QueryOp

type QueryOp struct {
	ResultObject IMultiResult
	Arguments    *QueryArguments
	// contains filtered or unexported fields
}

type String

type String struct {
	String string
	Valid  bool // Valid is true if String is not NULL
}

func NewString

func NewString(x string) *String

func NewStringStruct

func NewStringStruct(x string) String

func (String) GetName

func (nb String) GetName() string

func (String) MarshalJSON

func (ns String) MarshalJSON() ([]byte, error)

func (*String) UnmarshalJSON

func (ns *String) UnmarshalJSON(data []byte) error

type StringFilter

type StringFilter struct {
	Equal *String `json:"eq,omitempty"`
}

type Time

type Time struct {
	Time  time.Time
	Valid bool // Valid is true if Time is not NULL
}

func NewTime

func NewTime(x time.Time) *Time

func NewTimeStruct

func NewTimeStruct(x time.Time) Time

func (Time) GetName

func (nb Time) GetName() string

func (Time) MarshalJSON

func (nt Time) MarshalJSON() ([]byte, error)

func (*Time) UnmarshalJSON

func (nt *Time) UnmarshalJSON(data []byte) error

type UpdateOp

type UpdateOp struct {
	ResultObject IMutationResult
	Arguments    IIsUpdate
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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