Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb9d7f56fe |
@@ -227,7 +227,7 @@ type Query {
|
||||
getBondsByIds(ids: [String!]): [Bond]
|
||||
|
||||
# Query bonds.
|
||||
queryBonds: [Bond]
|
||||
queryBonds(attributes: [KeyValueInput!]): [Bond]
|
||||
|
||||
# Query bonds by owner.
|
||||
queryBondsByOwner(ownerAddresses: [String!]): [OwnerBonds]
|
||||
@@ -246,6 +246,8 @@ type Query {
|
||||
|
||||
# Whether to query all records, not just named ones (false by default).
|
||||
all: Boolean
|
||||
limit: Int
|
||||
offset: Int
|
||||
): [Record]
|
||||
|
||||
#
|
||||
|
||||
+57
-8
@@ -183,9 +183,9 @@ type ComplexityRoot struct {
|
||||
GetStatus func(childComplexity int) int
|
||||
LookupAuthorities func(childComplexity int, names []string) int
|
||||
LookupNames func(childComplexity int, names []string) int
|
||||
QueryBonds func(childComplexity int) int
|
||||
QueryBonds func(childComplexity int, attributes []*KeyValueInput) int
|
||||
QueryBondsByOwner func(childComplexity int, ownerAddresses []string) int
|
||||
QueryRecords func(childComplexity int, attributes []*KeyValueInput, all *bool) int
|
||||
QueryRecords func(childComplexity int, attributes []*KeyValueInput, all *bool, limit *int, offset *int) int
|
||||
ResolveNames func(childComplexity int, names []string) int
|
||||
}
|
||||
|
||||
@@ -233,10 +233,10 @@ type QueryResolver interface {
|
||||
GetStatus(ctx context.Context) (*Status, error)
|
||||
GetAccounts(ctx context.Context, addresses []string) ([]*Account, error)
|
||||
GetBondsByIds(ctx context.Context, ids []string) ([]*Bond, error)
|
||||
QueryBonds(ctx context.Context) ([]*Bond, error)
|
||||
QueryBonds(ctx context.Context, attributes []*KeyValueInput) ([]*Bond, error)
|
||||
QueryBondsByOwner(ctx context.Context, ownerAddresses []string) ([]*OwnerBonds, error)
|
||||
GetRecordsByIds(ctx context.Context, ids []string) ([]*Record, error)
|
||||
QueryRecords(ctx context.Context, attributes []*KeyValueInput, all *bool) ([]*Record, error)
|
||||
QueryRecords(ctx context.Context, attributes []*KeyValueInput, all *bool, limit *int, offset *int) ([]*Record, error)
|
||||
GetAuthorities(ctx context.Context, owner *string) ([]*Authority, error)
|
||||
LookupAuthorities(ctx context.Context, names []string) ([]*AuthorityRecord, error)
|
||||
LookupNames(ctx context.Context, names []string) ([]*NameRecord, error)
|
||||
@@ -844,7 +844,12 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.Query.QueryBonds(childComplexity), true
|
||||
args, err := ec.field_Query_queryBonds_args(context.TODO(), rawArgs)
|
||||
if err != nil {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
return e.complexity.Query.QueryBonds(childComplexity, args["attributes"].([]*KeyValueInput)), true
|
||||
|
||||
case "Query.queryBondsByOwner":
|
||||
if e.complexity.Query.QueryBondsByOwner == nil {
|
||||
@@ -868,7 +873,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
||||
return 0, false
|
||||
}
|
||||
|
||||
return e.complexity.Query.QueryRecords(childComplexity, args["attributes"].([]*KeyValueInput), args["all"].(*bool)), true
|
||||
return e.complexity.Query.QueryRecords(childComplexity, args["attributes"].([]*KeyValueInput), args["all"].(*bool), args["limit"].(*int), args["offset"].(*int)), true
|
||||
|
||||
case "Query.resolveNames":
|
||||
if e.complexity.Query.ResolveNames == nil {
|
||||
@@ -1289,6 +1294,21 @@ func (ec *executionContext) field_Query_queryBondsByOwner_args(ctx context.Conte
|
||||
return args, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Query_queryBonds_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
|
||||
var err error
|
||||
args := map[string]interface{}{}
|
||||
var arg0 []*KeyValueInput
|
||||
if tmp, ok := rawArgs["attributes"]; ok {
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("attributes"))
|
||||
arg0, err = ec.unmarshalOKeyValueInput2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐKeyValueInputᚄ(ctx, tmp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
args["attributes"] = arg0
|
||||
return args, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Query_queryRecords_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
|
||||
var err error
|
||||
args := map[string]interface{}{}
|
||||
@@ -1310,6 +1330,24 @@ func (ec *executionContext) field_Query_queryRecords_args(ctx context.Context, r
|
||||
}
|
||||
}
|
||||
args["all"] = arg1
|
||||
var arg2 *int
|
||||
if tmp, ok := rawArgs["limit"]; ok {
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("limit"))
|
||||
arg2, err = ec.unmarshalOInt2ᚖint(ctx, tmp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
args["limit"] = arg2
|
||||
var arg3 *int
|
||||
if tmp, ok := rawArgs["offset"]; ok {
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("offset"))
|
||||
arg3, err = ec.unmarshalOInt2ᚖint(ctx, tmp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
args["offset"] = arg3
|
||||
return args, nil
|
||||
}
|
||||
|
||||
@@ -4558,7 +4596,7 @@ func (ec *executionContext) _Query_queryBonds(ctx context.Context, field graphql
|
||||
}()
|
||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
||||
ctx = rctx // use context from middleware stack in children
|
||||
return ec.resolvers.Query().QueryBonds(rctx)
|
||||
return ec.resolvers.Query().QueryBonds(rctx, fc.Args["attributes"].([]*KeyValueInput))
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
@@ -4590,6 +4628,17 @@ func (ec *executionContext) fieldContext_Query_queryBonds(ctx context.Context, f
|
||||
return nil, fmt.Errorf("no field named %q was found under type Bond", field.Name)
|
||||
},
|
||||
}
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
err = ec.Recover(ctx, r)
|
||||
ec.Error(ctx, err)
|
||||
}
|
||||
}()
|
||||
ctx = graphql.WithFieldContext(ctx, fc)
|
||||
if fc.Args, err = ec.field_Query_queryBonds_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
|
||||
ec.Error(ctx, err)
|
||||
return
|
||||
}
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
@@ -4735,7 +4784,7 @@ func (ec *executionContext) _Query_queryRecords(ctx context.Context, field graph
|
||||
}()
|
||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
||||
ctx = rctx // use context from middleware stack in children
|
||||
return ec.resolvers.Query().QueryRecords(rctx, fc.Args["attributes"].([]*KeyValueInput), fc.Args["all"].(*bool))
|
||||
return ec.resolvers.Query().QueryRecords(rctx, fc.Args["attributes"].([]*KeyValueInput), fc.Args["all"].(*bool), fc.Args["limit"].(*int), fc.Args["offset"].(*int))
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
|
||||
+9
-2
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
types "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
|
||||
@@ -136,14 +137,20 @@ func (q queryResolver) LookupNames(ctx context.Context, names []string) ([]*Name
|
||||
return gqlResponse, nil
|
||||
}
|
||||
|
||||
func (q queryResolver) QueryRecords(ctx context.Context, attributes []*KeyValueInput, all *bool) ([]*Record, error) {
|
||||
func (q queryResolver) QueryRecords(ctx context.Context, attributes []*KeyValueInput, all *bool, limit *int, offset *int) ([]*Record, error) {
|
||||
nsQueryClient := registrytypes.NewQueryClient(q.ctx)
|
||||
|
||||
pagination := &query.PageRequest{
|
||||
Limit: uint64(*limit),
|
||||
Offset: uint64(*offset),
|
||||
}
|
||||
|
||||
res, err := nsQueryClient.Records(
|
||||
context.Background(),
|
||||
®istrytypes.QueryRecordsRequest{
|
||||
Attributes: toRPCAttributes(attributes),
|
||||
All: (all != nil && *all),
|
||||
Pagination: pagination,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
@@ -296,7 +303,7 @@ func (q *queryResolver) GetBond(ctx context.Context, id string) (*Bond, error) {
|
||||
return getGQLBond(bondResp.GetBond())
|
||||
}
|
||||
|
||||
func (q queryResolver) QueryBonds(ctx context.Context) ([]*Bond, error) {
|
||||
func (q queryResolver) QueryBonds(ctx context.Context, attributes []*KeyValueInput) ([]*Bond, error) {
|
||||
bondQueryClient := bondtypes.NewQueryClient(q.ctx)
|
||||
bonds, err := bondQueryClient.Bonds(context.Background(), &bondtypes.QueryBondsRequest{})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user