query

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Block = graphql.NewObject(
	graphql.ObjectConfig{
		Name: "Block",
		Fields: graphql.Fields{
			"header": &graphql.Field{
				Type: Header,
			},
			"transactions": &graphql.Field{
				Type:    graphql.NewList(Transaction),
				Resolve: resolveTxs,
			},
		},
	},
)
View Source
var Header = graphql.NewObject(
	graphql.ObjectConfig{
		Name: "Header",
		Fields: graphql.Fields{
			"height": &graphql.Field{
				Type: graphql.Int,
			},
			"hash": &graphql.Field{
				Type: Hex,
			},
			"version": &graphql.Field{
				Type: graphql.String,
			},
			"prevblockhash": &graphql.Field{
				Type: Hex,
			},
			"seed": &graphql.Field{
				Type: Hex,
			},
			"txroot": &graphql.Field{
				Type: Hex,
			},
			"timestamp": &graphql.Field{
				Type: UnixTimestamp,
			},
		},
	},
)
View Source
var Hex = graphql.NewScalar(graphql.ScalarConfig{
	Name:        "Hex",
	Description: "Hex scalar type represents a byte array",

	Serialize: func(value interface{}) interface{} {
		switch value := value.(type) {
		case []byte:
			return hex.EncodeToString(value)
		default:
			return nil
		}
	},

	ParseValue: func(value interface{}) interface{} {
		switch value := value.(type) {
		case string:
			bytes, _ := hex.DecodeString(value)
			return bytes
		default:
			return nil
		}
	},

	ParseLiteral: func(valueAST ast.Value) interface{} {

		return nil
	},
})
View Source
var Input = graphql.NewObject(
	graphql.ObjectConfig{
		Name: "Input",
		Fields: graphql.Fields{
			"keyimage": &graphql.Field{
				Type: Hex,
			},
		},
	},
)
View Source
var Output = graphql.NewObject(
	graphql.ObjectConfig{
		Name: "Output",
		Fields: graphql.Fields{
			"pubkey": &graphql.Field{
				Type: Hex,
			},
		},
	},
)
View Source
var Transaction = graphql.NewObject(
	graphql.ObjectConfig{
		Name: "Transaction",
		Fields: graphql.Fields{
			"txid": &graphql.Field{
				Type: Hex,
			},
			"txtype": &graphql.Field{
				Type: graphql.String,
			},
			"blockhash": &graphql.Field{
				Type: Hex,
			},
			"output": &graphql.Field{
				Type: graphql.NewList(Output),
			},
			"input": &graphql.Field{
				Type: graphql.NewList(Input),
			},
			"score": &graphql.Field{
				Type: Hex,
			},
			"size": &graphql.Field{
				Type: graphql.Int,
			},
		},
	},
)
View Source
var UnixTimestamp = graphql.NewScalar(graphql.ScalarConfig{
	Name:        "UnixTimestamp",
	Description: "UnixTimestamp scalar type represents a unix time field",

	Serialize: func(value interface{}) interface{} {
		switch value := value.(type) {
		case int64:
			tm := time.Unix(value, 0)
			return tm.String()
		default:
			return nil
		}
	},

	ParseValue: func(value interface{}) interface{} {

		return nil
	},

	ParseLiteral: func(valueAST ast.Value) interface{} {

		return nil
	},
})

Functions

This section is empty.

Types

type Root

type Root struct {
	Query *graphql.Object
}

func NewRoot

func NewRoot(rpcBus *rpcbus.RPCBus) *Root

Jump to

Keyboard shortcuts

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