gql

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2020 License: GPL-3.0 Imports: 32 Imported by: 0

README

WNS GQL Server

Web UI Queries

Basic node status:

{
  getStatus {
    version
    node {
      id
      network
      moniker
    }
    sync {
      latest_block_height
      catching_up
    }
    num_peers
    peers {
      is_outbound
      remote_ip
    }
    disk_usage
  }
}

Full node status:

{
  getStatus {
    version
    node {
      id
      network
      moniker
    }
    sync {
      latest_block_hash
      latest_block_time
      latest_block_height
      catching_up
    }
    validator {
      address
      voting_power
      proposer_priority
    }
    validators {
      address
      voting_power
      proposer_priority
    }
    num_peers
    peers {
      node {
        id
        network
        moniker
      }
      is_outbound
      remote_ip
    }
    disk_usage
  }
}

Get account details:

{
  getAccounts(addresses: ["cosmos1wh8vvd0ymc5nt37h29z8kk2g2ays45ct2qu094"]) {
    address
    pubKey
    number
    sequence
    balance {
      type
      quantity
    }
  }
}

Get bonds by IDs.

{
  getBondsByIds(
    ids: ["8e340dd7cf6fc91c27eeefce9cca1406c262e93fd6f3a4f3b1e99b01161fcef3"]
  ) {
    id
    owner
    balance {
      type
      quantity
    }
  }
}

Query bonds:

{
  queryBonds(
    attributes: [
      {
        key: "owner"
        value: { string: "cosmos1wh8vvd0ymc5nt37h29z8kk2g2ays45ct2qu094" }
      }
    ]
  ) {
    id
    owner
    balance {
      type
      quantity
    }
  }
}

Get records by IDs.

{
  getRecordsByIds(ids: ["QmYDtNCKtTu6u6jaHaFAC5PWZXcj7fAmry6NoWwMaixFHz"]) {
    id
    type
    name
    version
  }
}

Query records.

{
  queryRecords(attributes: [{ key: "type", value: { string: "wrn:bot" } }]) {
    id
    type
    name
    version
    bondId
    createTime
    expiryTime
    owners
    attributes {
      key
      value {
        string
      }
    }
  }
}

Resolve records.

{
  resolveRecords(refs: ["wrn:bot:wireline.io/echo-bot"]) {
    id
    type
    name
    version
  }
}

Documentation

Index

Constants

View Source
const BondIDAttributeName = "bondId"

BondIDAttributeName denotes the record bond ID.

View Source
const DefaultLogNumLines = 50

DefaultLogNumLines is the number of log lines to tail by default.

View Source
const ExpiryTimeAttributeName = "expiryTime"

ExpiryTimeAttributeName denotes the record expiry time.

View Source
const MaxLogNumLines = 1000

MaxLogNumLines is the max number of log lines that can be tailed.

View Source
const NamserviceVersion = "0.3.0"

NamserviceVersion is the registry API version.

View Source
const OwnerAttributeName = "owner"

OwnerAttributeName denotes the owner attribute name for a bond.

Variables

View Source
var NodeDataPath = os.ExpandEnv("$HOME/.wire/wnsd/data")

NodeDataPath is the path to the wnsd data folder.

Functions

func GetDiskUsage

func GetDiskUsage(dirPath string) (string, error)

GetDiskUsage returns disk usage for the given path.

func GetLogs added in v0.5.1

func GetLogs(ctx context.Context, logFile string, count *int) ([]string, error)

GetLogs tails the log file.

func MatchOnAttributes

func MatchOnAttributes(record *nameservice.Record, attributes []*KeyValueInput, all bool) bool

func NewExecutableSchema

func NewExecutableSchema(cfg Config) graphql.ExecutableSchema

NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.

func Server

func Server(baseApp *bam.BaseApp, cdc *codec.Codec, keeper nameservice.Keeper, bondKeeper bond.Keeper, accountKeeper auth.AccountKeeper)

Server configures and starts the GQL server.

Types

type Account

type Account struct {
	Address  string  `json:"address"`
	PubKey   *string `json:"pubKey"`
	Number   string  `json:"number"`
	Sequence string  `json:"sequence"`
	Balance  []Coin  `json:"balance"`
}

type AuthorityRecord added in v0.6.0

type AuthorityRecord struct {
	OwnerAddress   string `json:"ownerAddress"`
	OwnerPublicKey string `json:"ownerPublicKey"`
	Height         string `json:"height"`
}

func GetGQLNameAuthorityRecord added in v0.6.0

func GetGQLNameAuthorityRecord(ctx context.Context, resolver QueryResolver, record *nameservice.NameAuthority) (*AuthorityRecord, error)

type AuthorityResult added in v0.6.0

type AuthorityResult struct {
	Meta    ResultMeta         `json:"meta"`
	Records []*AuthorityRecord `json:"records"`
}

type Bond

type Bond struct {
	ID      string `json:"id"`
	Owner   string `json:"owner"`
	Balance []Coin `json:"balance"`
}

type Coin

type Coin struct {
	Type     string `json:"type"`
	Quantity string `json:"quantity"`
}

type ComplexityRoot

type ComplexityRoot struct {
	Account struct {
		Address  func(childComplexity int) int
		PubKey   func(childComplexity int) int
		Number   func(childComplexity int) int
		Sequence func(childComplexity int) int
		Balance  func(childComplexity int) int
	}

	AuthorityRecord struct {
		OwnerAddress   func(childComplexity int) int
		OwnerPublicKey func(childComplexity int) int
		Height         func(childComplexity int) int
	}

	AuthorityResult struct {
		Meta    func(childComplexity int) int
		Records func(childComplexity int) int
	}

	Bond struct {
		ID      func(childComplexity int) int
		Owner   func(childComplexity int) int
		Balance func(childComplexity int) int
	}

	Coin struct {
		Type     func(childComplexity int) int
		Quantity func(childComplexity int) int
	}

	KeyValue struct {
		Key   func(childComplexity int) int
		Value func(childComplexity int) int
	}

	Mutation struct {
		InsertRecord func(childComplexity int, attributes []*KeyValueInput) int
		Submit       func(childComplexity int, tx string) int
	}

	NameRecord struct {
		Latest  func(childComplexity int) int
		History func(childComplexity int) int
	}

	NameRecordEntry struct {
		ID     func(childComplexity int) int
		Height func(childComplexity int) int
	}

	NameResult struct {
		Meta    func(childComplexity int) int
		Records func(childComplexity int) int
	}

	NodeInfo struct {
		ID      func(childComplexity int) int
		Network func(childComplexity int) int
		Moniker func(childComplexity int) int
	}

	PeerInfo struct {
		Node       func(childComplexity int) int
		IsOutbound func(childComplexity int) int
		RemoteIP   func(childComplexity int) int
	}

	Query struct {
		GetStatus         func(childComplexity int) int
		GetLogs           func(childComplexity int, count *int) int
		GetAccounts       func(childComplexity int, addresses []string) int
		GetBondsByIds     func(childComplexity int, ids []string) int
		QueryBonds        func(childComplexity int, attributes []*KeyValueInput) int
		GetRecordsByIds   func(childComplexity int, ids []string) int
		QueryRecords      func(childComplexity int, attributes []*KeyValueInput, all *bool) int
		LookupAuthorities func(childComplexity int, names []string) int
		LookupNames       func(childComplexity int, names []string) int
		ResolveNames      func(childComplexity int, names []string) int
	}

	Record struct {
		ID         func(childComplexity int) int
		Names      func(childComplexity int) int
		BondID     func(childComplexity int) int
		CreateTime func(childComplexity int) int
		ExpiryTime func(childComplexity int) int
		Owners     func(childComplexity int) int
		Attributes func(childComplexity int) int
		References func(childComplexity int) int
	}

	RecordResult struct {
		Meta    func(childComplexity int) int
		Records func(childComplexity int) int
	}

	Reference struct {
		ID func(childComplexity int) int
	}

	ResultMeta struct {
		Height func(childComplexity int) int
	}

	Status struct {
		Version    func(childComplexity int) int
		Node       func(childComplexity int) int
		Sync       func(childComplexity int) int
		Validator  func(childComplexity int) int
		Validators func(childComplexity int) int
		NumPeers   func(childComplexity int) int
		Peers      func(childComplexity int) int
		DiskUsage  func(childComplexity int) int
	}

	SyncInfo struct {
		LatestBlockHash   func(childComplexity int) int
		LatestBlockHeight func(childComplexity int) int
		LatestBlockTime   func(childComplexity int) int
		CatchingUp        func(childComplexity int) int
	}

	ValidatorInfo struct {
		Address          func(childComplexity int) int
		VotingPower      func(childComplexity int) int
		ProposerPriority func(childComplexity int) int
	}

	Value struct {
		Null      func(childComplexity int) int
		Int       func(childComplexity int) int
		Float     func(childComplexity int) int
		String    func(childComplexity int) int
		Boolean   func(childComplexity int) int
		JSON      func(childComplexity int) int
		Reference func(childComplexity int) int
		Values    func(childComplexity int) int
	}
}

type Config

type Config struct {
	Resolvers  ResolverRoot
	Directives DirectiveRoot
	Complexity ComplexityRoot
}

type DirectiveRoot

type DirectiveRoot struct {
}

type KeyValue

type KeyValue struct {
	Key   string `json:"key"`
	Value Value  `json:"value"`
}

type KeyValueInput

type KeyValueInput struct {
	Key   string     `json:"key"`
	Value ValueInput `json:"value"`
}

type MutationResolver

type MutationResolver interface {
	InsertRecord(ctx context.Context, attributes []*KeyValueInput) (*Record, error)
	Submit(ctx context.Context, tx string) (*string, error)
}

type NameRecord added in v0.6.0

type NameRecord struct {
	Latest  NameRecordEntry    `json:"latest"`
	History []*NameRecordEntry `json:"history"`
}

func GetGQLNameRecord added in v0.6.0

func GetGQLNameRecord(ctx context.Context, resolver QueryResolver, record *nameservice.NameRecord) (*NameRecord, error)

type NameRecordEntry added in v0.6.0

type NameRecordEntry struct {
	ID     string `json:"id"`
	Height string `json:"height"`
}

type NameResult added in v0.6.0

type NameResult struct {
	Meta    ResultMeta    `json:"meta"`
	Records []*NameRecord `json:"records"`
}

type NodeInfo

type NodeInfo struct {
	ID      string `json:"id"`
	Network string `json:"network"`
	Moniker string `json:"moniker"`
}

type PeerInfo

type PeerInfo struct {
	Node       NodeInfo `json:"node"`
	IsOutbound bool     `json:"is_outbound"`
	RemoteIP   string   `json:"remote_ip"`
}

type QueryResolver

type QueryResolver interface {
	GetStatus(ctx context.Context) (*Status, error)
	GetLogs(ctx context.Context, count *int) ([]string, error)
	GetAccounts(ctx context.Context, addresses []string) ([]*Account, error)
	GetBondsByIds(ctx context.Context, ids []string) ([]*Bond, error)
	QueryBonds(ctx context.Context, attributes []*KeyValueInput) ([]*Bond, error)
	GetRecordsByIds(ctx context.Context, ids []string) ([]*Record, error)
	QueryRecords(ctx context.Context, attributes []*KeyValueInput, all *bool) ([]*Record, error)
	LookupAuthorities(ctx context.Context, names []string) (*AuthorityResult, error)
	LookupNames(ctx context.Context, names []string) (*NameResult, error)
	ResolveNames(ctx context.Context, names []string) (*RecordResult, error)
}

type Record

type Record struct {
	ID         string      `json:"id"`
	Names      []string    `json:"names"`
	BondID     string      `json:"bondId"`
	CreateTime string      `json:"createTime"`
	ExpiryTime string      `json:"expiryTime"`
	Owners     []*string   `json:"owners"`
	Attributes []*KeyValue `json:"attributes"`
	References []*Record   `json:"references"`
}

func GetGQLRecord

func GetGQLRecord(ctx context.Context, resolver QueryResolver, record *nameservice.Record) (*Record, error)

func QueryRecords

func QueryRecords(ctx context.Context, resolver QueryResolver, records []*nameservice.Record, attributes []*KeyValueInput) ([]*Record, error)

QueryRecords filters records by K=V conditions.

type RecordResult added in v0.6.0

type RecordResult struct {
	Meta    ResultMeta `json:"meta"`
	Records []*Record  `json:"records"`
}

type Reference

type Reference struct {
	ID string `json:"id"`
}

type ReferenceInput

type ReferenceInput struct {
	ID string `json:"id"`
}

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver is the GQL query resolver.

func (*Resolver) Mutation

func (r *Resolver) Mutation() MutationResolver

Mutation is the entry point to tx execution.

func (*Resolver) Query

func (r *Resolver) Query() QueryResolver

Query is the entry point to query execution.

type ResolverRoot

type ResolverRoot interface {
	Mutation() MutationResolver
	Query() QueryResolver
}

type ResultMeta added in v0.6.0

type ResultMeta struct {
	Height string `json:"height"`
}

type Status

type Status struct {
	Version    string           `json:"version"`
	Node       NodeInfo         `json:"node"`
	Sync       SyncInfo         `json:"sync"`
	Validator  *ValidatorInfo   `json:"validator"`
	Validators []*ValidatorInfo `json:"validators"`
	NumPeers   string           `json:"num_peers"`
	Peers      []*PeerInfo      `json:"peers"`
	DiskUsage  string           `json:"disk_usage"`
}

type SyncInfo

type SyncInfo struct {
	LatestBlockHash   string `json:"latest_block_hash"`
	LatestBlockHeight string `json:"latest_block_height"`
	LatestBlockTime   string `json:"latest_block_time"`
	CatchingUp        bool   `json:"catching_up"`
}

type ValidatorInfo

type ValidatorInfo struct {
	Address          string  `json:"address"`
	VotingPower      string  `json:"voting_power"`
	ProposerPriority *string `json:"proposer_priority"`
}

type Value

type Value struct {
	Null      *bool      `json:"null"`
	Int       *int       `json:"int"`
	Float     *float64   `json:"float"`
	String    *string    `json:"string"`
	Boolean   *bool      `json:"boolean"`
	JSON      *string    `json:"json"`
	Reference *Reference `json:"reference"`
	Values    []*Value   `json:"values"`
}

type ValueInput

type ValueInput struct {
	Null      *bool           `json:"null"`
	Int       *int            `json:"int"`
	Float     *float64        `json:"float"`
	String    *string         `json:"string"`
	Boolean   *bool           `json:"boolean"`
	Reference *ReferenceInput `json:"reference"`
	Values    []*ValueInput   `json:"values"`
}

Jump to

Keyboard shortcuts

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