types

package
v0.14.43 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2025 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DurationScalar

type DurationScalar time.Duration

func ParseDurationScalar

func ParseDurationScalar(s string) (*DurationScalar, error)

func (DurationScalar) MarshalJSON

func (d DurationScalar) MarshalJSON() ([]byte, error)

func (DurationScalar) Ptr

func (d DurationScalar) Ptr() *DurationScalar

func (DurationScalar) String

func (d DurationScalar) String() string

func (*DurationScalar) UnmarshalJSON

func (d *DurationScalar) UnmarshalJSON(b []byte) error

type Int64Scalar

type Int64Scalar int64

func (Int64Scalar) Duration

func (n Int64Scalar) Duration() time.Duration

func (*Int64Scalar) IntPtr

func (n *Int64Scalar) IntPtr() *int

func (Int64Scalar) MarshalJSON

func (n Int64Scalar) MarshalJSON() ([]byte, error)

func (Int64Scalar) Ptr

func (n Int64Scalar) Ptr() *Int64Scalar

func (Int64Scalar) String

func (n Int64Scalar) String() string

func (*Int64Scalar) UnmarshalJSON

func (n *Int64Scalar) UnmarshalJSON(b []byte) error

type JsonObject

type JsonObject string

func (JsonObject) Map

func (o JsonObject) Map() (map[string]interface{}, error)

func (JsonObject) MarshalJSON

func (o JsonObject) MarshalJSON() ([]byte, error)

func (JsonObject) Ptr

func (o JsonObject) Ptr() *JsonObject

func (JsonObject) String

func (o JsonObject) String() string

func (*JsonObject) UnmarshalJSON

func (o *JsonObject) UnmarshalJSON(data []byte) error

type NumberScalar

type NumberScalar float64

func (NumberScalar) MarshalJSON

func (n NumberScalar) MarshalJSON() ([]byte, error)

func (NumberScalar) String

func (n NumberScalar) String() string

func (*NumberScalar) UnmarshalJSON

func (n *NumberScalar) UnmarshalJSON(data []byte) error

type TimeScalar

type TimeScalar time.Time

func (TimeScalar) MarshalJSON

func (t TimeScalar) MarshalJSON() ([]byte, error)

func (TimeScalar) String

func (t TimeScalar) String() string

func (*TimeScalar) UnmarshalJSON

func (t *TimeScalar) UnmarshalJSON(b []byte) error

type UserIdScalar

type UserIdScalar int64

func StringToUserIdScalar

func StringToUserIdScalar(id string) (UserIdScalar, error)

func (UserIdScalar) MarshalJSON

func (u UserIdScalar) MarshalJSON() ([]byte, error)

func (UserIdScalar) String

func (u UserIdScalar) String() string

func (*UserIdScalar) UnmarshalJSON

func (u *UserIdScalar) UnmarshalJSON(b []byte) error

type Value

type Value struct {
	// ValueData holds the concrete value in one field based on the given type
	ValueData

	// NullValueType stores the type of a Value that is null, since this cannot be
	// inferred from the other fields, which will all be nil.
	NullValueType ValueType `json:"-"`
}

Value is a GraphQL type representing a value that may be one of many supported types (ValueType). When represented as JSON, exactly one field must be set. A null value of a given type is represented with null value in JSON, e.g.,: {"bool": null}

func MustNewValue

func MustNewValue(v any) *Value

MustNewValue returns a Value for the given Go type. It panics if the type is not supported.

func NewNullValue

func NewNullValue(t ValueType) *Value

NewNullValue returns a Value that is null of the given type.

func (Value) MarshalJSON

func (v Value) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface. If the value is null, it returns a null value for the given type, e.g.,: {"bool": null} Otherwise, it returns the value in the corresponding field.

func (*Value) UnmarshalJSON

func (v *Value) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface. It handles null values of a given type, e.g.,: {"bool": null} It also strips extra nulls for backwards compatibility: {"bool": true, "float64": null, ...}

It rejects values that have more than one field set or where all fields are null.

type ValueArray

type ValueArray struct {
	Value []*Value `json:"value,omitempty"`
}

type ValueData

type ValueData struct {
	Bool       *bool            `json:"bool,omitempty"`
	Float64    *NumberScalar    `json:"float64,omitempty"`
	Int64      *Int64Scalar     `json:"int64,omitempty"`
	String     *string          `json:"string,omitempty"`
	Timestamp  *TimeScalar      `json:"timestamp,omitempty"`
	Duration   *DurationScalar  `json:"duration,omitempty"`
	Array      *ValueArray      `json:"array,omitempty"`
	Link       *ValueLink       `json:"link,omitempty"`
	Datasetref *ValueDatasetref `json:"datasetref,omitempty"`
}

ValueData holds a concrete non-null value of one of the supported types.

type ValueDatasetref

type ValueDatasetref struct {
	DatasetId   *string `json:"datasetId,omitempty"`
	DatasetPath *string `json:"datasetPath,omitempty"`
	StageId     *string `json:"stageId,omitempty"`
}

type ValueKeyValue

type ValueKeyValue struct {
	Name  string `json:"name,omitempty"`
	Value *Value `json:"value,omitempty"`
}
type ValueLink struct {
	DatasetId       string           `json:"datasetId,omitempty"`
	PrimaryKeyValue []*ValueKeyValue `json:"primaryKeyValue,omitempty"`
	StoredLabel     *string          `json:"storedLabel,omitempty"`
}

type ValueType

type ValueType string

ValueType is an supported type of a Value.

const (
	ValueTypeBool       ValueType = "bool"
	ValueTypeFloat64    ValueType = "float64"
	ValueTypeInt64      ValueType = "int64"
	ValueTypeString     ValueType = "string"
	ValueTypeTimestamp  ValueType = "timestamp"
	ValueTypeDuration   ValueType = "duration"
	ValueTypeArray      ValueType = "array"
	ValueTypeObject     ValueType = "object"
	ValueTypeLink       ValueType = "link"
	ValueTypeDatasetref ValueType = "datasetref"
)

func ValueTypeOf

func ValueTypeOf[V any](m map[ValueType]*V) (ValueType, error)

ValueTypeOf is a generic function that returns the ValueType of a map based on its non-nil values. It returns an error if too many or too few values are set.

Jump to

Keyboard shortcuts

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