graphql

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2025 License: Unlicense Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Bytes = gql.NewScalar(gql.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)
		case string:
			return value
		default:
			return nil
		}
	},
	ParseValue: func(value interface{}) interface{} {
		switch value := value.(type) {
		case string:
			return DecodeBytes(value)
		case []byte:
			return 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 = gql.NewScalar(
	gql.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 Enum

func Enum(desc protoreflect.EnumDescriptor) *gql.Enum

func Object

Types

This section is empty.

Jump to

Keyboard shortcuts

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