graphql

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxAuthenticatedQueryComplexity = 30000
	MaxAnonymousQueryComplexity     = 500
)

Variables

This section is empty.

Functions

func GetComplexity

func GetComplexity(t reflect.Type) int

func WithPaginatedQueryLimit

func WithPaginatedQueryLimit(limit int) func(options *PaginatedQueryGetOptions)

Types

type AssetIdParams

type AssetIdParams struct {
	AssetId string `graphql:"assetId"`
}

type AssetIdsParams

type AssetIdsParams struct {
	AssetIds []string `graphql:"assetIds"`
}

type BlockchainIdParams

type BlockchainIdParams struct {
	BlockchainId string `graphql:"blockchainId"`
}

type Client

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

func NewClient

func NewClient(httpclient *http.Client, baseUrl string) *Client

func (*Client) Authenticate

func (c *Client) Authenticate(
	ctx context.Context,
	email string,
	password string,
	audience string,
	otp string,
) error

func (*Client) ConstructRawQuery

func (c *Client) ConstructRawQuery(q interface{}, variables map[string]interface{}) (string, error)

func (*Client) GetCurrentToken

func (c *Client) GetCurrentToken() JwtToken

func (*Client) MaxComplexity

func (c *Client) MaxComplexity() int

func (*Client) Mutate

func (c *Client) Mutate(ctx context.Context, q interface{}, variables interface{}, options ...graphql.Option) error

func (*Client) Query

func (c *Client) Query(ctx context.Context, q interface{}, variables interface{}, options ...graphql.Option) error

func (*Client) SetJWTToken

func (c *Client) SetJWTToken(token JwtToken, audience string)

type ContainerLayer

type ContainerLayer[T any, P any] interface {
	GetInnerLayer() ContainerLayer[T, P]
	GetValue() T
	GetGraphQLType() string
}

type EmptyParams

type EmptyParams struct {
}

type Id

type Id struct {
	Type  string
	Value string
}

func (Id) MarshalJSON

func (i Id) MarshalJSON() ([]byte, error)

func (Id) String

func (i Id) String() string

func (*Id) UnmarshalJSON

func (i *Id) UnmarshalJSON(bytes []byte) error

type IdParams

type IdParams struct {
	Id gql.ID `graphql:"id"`
}

type IdStringParams

type IdStringParams struct {
	Id string `graphql:"id"`
}

type IdStringsParams

type IdStringsParams struct {
	Ids []string `graphql:"ids"`
}

type IdsParams

type IdsParams struct {
	Ids []gql.ID `graphql:"ids"`
}

type JwtToken

type JwtToken struct {
	Token     string
	ExpiredAt time.Time
}

type Mutation

type Mutation[Payload any, Params any] struct {
	// contains filtered or unexported fields
}

func NewMutation

func NewMutation[Payload any, Params any](c *Client, gqlType string) *Mutation[Payload, Params]

func (*Mutation[Payload, Params]) Execute

func (m *Mutation[Payload, Params]) Execute(ctx context.Context, params Params) (Payload, error)

func (*Mutation[Payload, Params]) WithPayloadParam

func (m *Mutation[Payload, Params]) WithPayloadParam(name string, value interface{}) *Mutation[Payload, Params]

func (*Mutation[Payload, Params]) WithQueryParam

func (m *Mutation[Payload, Params]) WithQueryParam(name string, value interface{}) *Mutation[Payload, Params]

type NestedLayer

type NestedLayer[T any, P any] struct {
	InnerLayer ContainerLayer[T, P]
	// contains filtered or unexported fields
}

func (*NestedLayer[T, P]) GetGraphQLType

func (nl *NestedLayer[T, P]) GetGraphQLType() string

func (*NestedLayer[T, P]) GetInnerLayer

func (nl *NestedLayer[T, P]) GetInnerLayer() ContainerLayer[T, P]

func (*NestedLayer[T, P]) GetValue

func (nl *NestedLayer[T, P]) GetValue() T

type PageInfo

type PageInfo struct {
	EndCursor       string `graphql:"endCursor"`
	HasNextPage     bool   `graphql:"hasNextPage"`
	HasPreviousPage bool   `graphql:"hasPreviousPage"`
	StartCursor     string `graphql:"startCursor"`
}

type PaginatedQuery

type PaginatedQuery[ResultType any, Params any] struct {
	// contains filtered or unexported fields
}

func NewPaginatedQuery

func NewPaginatedQuery[ResultType any, Params any](
	c *Client,
	gqlType string,
	containerLayers []string,
) *PaginatedQuery[ResultType, Params]

func (*PaginatedQuery[ResultType, Params]) Get

func (pq *PaginatedQuery[ResultType, Params]) Get(
	ctx context.Context,
	params Params,
	options ...func(options *PaginatedQueryGetOptions),
) ([]ResultType, error)

func (*PaginatedQuery[ResultType, Params]) WithPayloadParam

func (pq *PaginatedQuery[ResultType, Params]) WithPayloadParam(
	name string,
	value interface{},
) *PaginatedQuery[ResultType, Params]

func (*PaginatedQuery[ResultType, Params]) WithQueryParam

func (pq *PaginatedQuery[ResultType, Params]) WithQueryParam(
	name string,
	value interface{},
) *PaginatedQuery[ResultType, Params]

type PaginatedQueryGetOptions

type PaginatedQueryGetOptions struct {
	Limit int
}

type Payload

type Payload[T any, P any] struct {
	OutermostLayer ContainerLayer[T, P]
}

func NewPayload

func NewPayload[T any, P any](gqlType string, containerLayers ...string) *Payload[T, P]

func (*Payload[T, P]) GetValue

func (q *Payload[T, P]) GetValue() T

type Query

type Query[ReturnType any, Params any] struct {
	// contains filtered or unexported fields
}

func NewQuery

func NewQuery[ReturnType any, Params any](c *Client, gqlType string, containerLayers []string) *Query[ReturnType, Params]

func (*Query[ReturnType, Params]) Get

func (r *Query[ReturnType, Params]) Get(ctx context.Context, params Params) (ReturnType, error)

func (*Query[ReturnType, Params]) WithPayloadParam

func (r *Query[ReturnType, Params]) WithPayloadParam(name string, value interface{}) *Query[ReturnType, Params]

func (*Query[ReturnType, Params]) WithQueryParam

func (r *Query[ReturnType, Params]) WithQueryParam(name string, value interface{}) *Query[ReturnType, Params]

type SignIn

type SignIn struct {
	CurrentUser struct {
		Slug     string
		JwtToken JwtToken `graphql:"jwtToken(aud: $aud)"`
	} `graphql:"currentUser"`
	OtpSessionChallenge string
	Errors              []struct {
		Message string
	} `graphql:"errors"`
}

type SignInMutation

type SignInMutation struct {
	*Mutation[SignIn, SignInParams]
}

func NewSignInMutation

func NewSignInMutation(c *Client, audience string) *SignInMutation

type SignInParams

type SignInParams struct {
	Input signInInput `graphql:"input"`
}

type SlugParams

type SlugParams struct {
	Slug string `graphql:"slug"`
}

type SlugsParams

type SlugsParams struct {
	Slugs []string `graphql:"slugs"`
}

type Wrapper

type Wrapper[T any, P any] struct {
	Value T
	// contains filtered or unexported fields
}

func NewWrapper

func NewWrapper[T any, P any](gqlType string) *Wrapper[T, P]

func (Wrapper[T, P]) GetGraphQLType

func (w Wrapper[T, P]) GetGraphQLType() string

func (Wrapper[T, P]) GetGraphQLWrapped

func (w Wrapper[T, P]) GetGraphQLWrapped() T

func (Wrapper[T, P]) GetInnerLayer

func (w Wrapper[T, P]) GetInnerLayer() ContainerLayer[T, P]

func (Wrapper[T, P]) GetValue

func (w Wrapper[T, P]) GetValue() T

Jump to

Keyboard shortcuts

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