scalars

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DoubleStringScalarConfig = actograph.ScalarConfig{
	Name:        "DoubleString",
	Description: "Just double the original string",
	Serialize: func(value interface{}) interface{} {
		strVal, ok := value.(string)
		if !ok {
			panic("value should be string")
		}
		return fmt.Sprintf("%s%s", strVal, strVal)
	},
	ParseValue: func(value interface{}) interface{} {
		stringValue, ok := value.(string)
		if !ok {
			panic("value should be in string")
		}
		return fmt.Sprintf("%s%s", stringValue, stringValue)
	},
	ParseLiteral: func(valueAST ast.Value) interface{} {
		if valueAST.GetKind() != "StringValue" {
			panic("only strings as literal allowed")
		}
		val := valueAST.GetValue().(string)
		return fmt.Sprintf("%s%s", val, val)
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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