utils

package
v0.6.12 Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: MIT Imports: 7 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Bytes = graphql.NewScalar(graphql.ScalarConfig{
	Name:        "Bytes",
	Description: "Bytes scalar to encode []byte to base64 string and decode base64 string to []byte",
	Serialize: func(value interface{}) interface{} {
		switch value := value.(type) {
		case []byte:
			return base64.StdEncoding.EncodeToString(value)
		default:
			return nil
		}
	},
	ParseValue: func(value interface{}) interface{} {
		switch value := value.(type) {
		case string:
			return DecodeBytes(value)
		default:
			return nil
		}
	},
	ParseLiteral: func(valueAST ast.Value) interface{} {
		return nil
	},
})

Custom scalar type for []byte to base64 string and vice versa

View Source
var JSON = graphql.NewScalar(
	graphql.ScalarConfig{
		Name:        "JSON",
		Description: "The `JSON` scalar type represents JSON values as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf)",
		Serialize: func(value interface{}) interface{} {
			return value
		},
		ParseValue: func(value interface{}) interface{} {
			return value
		},
		ParseLiteral: parseLiteralJSON,
	},
)

JSON json type

Functions

func DecodeBytes

func DecodeBytes(input string) []byte

DecodeBytes ...

func MakeMap

func MakeMap(ptr interface{})

MakeMap ...

func MakeSlice

func MakeSlice(ptr interface{}, size int)

MakeSlice ...

func MapFromBytes added in v0.3.71

func MapFromBytes(data []byte) (res map[string]interface{}, err error)

MapFromBytes ...

func ParseFloat

func ParseFloat(s string) float64

ParseFloat ...

Types

type GraphqlArgument added in v0.6.3

type GraphqlArgument interface {
	// Argument ...
	Argument() graphql.FieldConfigArgument
}

GraphqlArgument ...

type GraphqlObject added in v0.3.73

type GraphqlObject interface {
	// Object ...
	Object() *graphql.Object
}

GraphqlObject ...

type GraphqlOutput added in v0.6.0

type GraphqlOutput interface {
	// Output ...
	Output() graphql.Output
}

GraphqlOutput ...

type Message added in v0.3.71

type Message interface {
	Schema() map[string]interface{}
}

Message ...

type Unmarshaler added in v0.3.71

type Unmarshaler interface {
	UnmarshalMap(m map[string]interface{})
}

Unmarshaler ...

Jump to

Keyboard shortcuts

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