Add GQL queries
This commit is contained in:
parent
f1f88a5470
commit
5e2920c0c2
@ -30,7 +30,7 @@ const (
|
||||
type QueryClient interface {
|
||||
// Participants queries Participants list
|
||||
Participants(ctx context.Context, in *QueryParticipantsRequest, opts ...grpc.CallOption) (*QueryParticipantsResponse, error)
|
||||
// Participants queries Participants list by laconic address
|
||||
// Participants queries Participants list by cosmos address
|
||||
GetParticipantByAddress(ctx context.Context, in *QueryGetParticipantByAddressRequest, opts ...grpc.CallOption) (*QueryGetParticipantByAddressResponse, error)
|
||||
// Participants queries Participants list by nitro address
|
||||
GetParticipantByNitroAddress(ctx context.Context, in *QueryGetParticipantByNitroAddressRequest, opts ...grpc.CallOption) (*QueryGetParticipantByNitroAddressResponse, error)
|
||||
@ -77,7 +77,7 @@ func (c *queryClient) GetParticipantByNitroAddress(ctx context.Context, in *Quer
|
||||
type QueryServer interface {
|
||||
// Participants queries Participants list
|
||||
Participants(context.Context, *QueryParticipantsRequest) (*QueryParticipantsResponse, error)
|
||||
// Participants queries Participants list by laconic address
|
||||
// Participants queries Participants list by cosmos address
|
||||
GetParticipantByAddress(context.Context, *QueryGetParticipantByAddressRequest) (*QueryGetParticipantByAddressResponse, error)
|
||||
// Participants queries Participants list by nitro address
|
||||
GetParticipantByNitroAddress(context.Context, *QueryGetParticipantByNitroAddressRequest) (*QueryGetParticipantByNitroAddressResponse, error)
|
||||
|
@ -265,4 +265,6 @@ type Query {
|
||||
|
||||
# Query participants.
|
||||
getParticipants: [Participant]!
|
||||
getParticipantByAddress(cosmosAddress: String!): Participant!
|
||||
getParticipantByNitroAddress(nitroAddress: String!): Participant!
|
||||
}
|
||||
|
272
gql/generated.go
272
gql/generated.go
@ -167,18 +167,20 @@ type ComplexityRoot struct {
|
||||
}
|
||||
|
||||
Query struct {
|
||||
GetAccounts func(childComplexity int, addresses []string) int
|
||||
GetAuctionsByIds func(childComplexity int, ids []string) int
|
||||
GetBondsByIds func(childComplexity int, ids []string) int
|
||||
GetParticipants func(childComplexity int) int
|
||||
GetRecordsByIds func(childComplexity int, ids []string) int
|
||||
GetStatus func(childComplexity int) int
|
||||
LookupAuthorities func(childComplexity int, names []string) int
|
||||
LookupNames func(childComplexity int, names []string) int
|
||||
QueryBonds func(childComplexity int, attributes []*KeyValueInput) int
|
||||
QueryBondsByOwner func(childComplexity int, ownerAddresses []string) int
|
||||
QueryRecords func(childComplexity int, attributes []*KeyValueInput, all *bool) int
|
||||
ResolveNames func(childComplexity int, names []string) int
|
||||
GetAccounts func(childComplexity int, addresses []string) int
|
||||
GetAuctionsByIds func(childComplexity int, ids []string) int
|
||||
GetBondsByIds func(childComplexity int, ids []string) int
|
||||
GetParticipantByAddress func(childComplexity int, cosmosAddress string) int
|
||||
GetParticipantByNitroAddress func(childComplexity int, nitroAddress string) int
|
||||
GetParticipants func(childComplexity int) int
|
||||
GetRecordsByIds func(childComplexity int, ids []string) int
|
||||
GetStatus func(childComplexity int) int
|
||||
LookupAuthorities func(childComplexity int, names []string) int
|
||||
LookupNames func(childComplexity int, names []string) int
|
||||
QueryBonds func(childComplexity int, attributes []*KeyValueInput) int
|
||||
QueryBondsByOwner func(childComplexity int, ownerAddresses []string) int
|
||||
QueryRecords func(childComplexity int, attributes []*KeyValueInput, all *bool) int
|
||||
ResolveNames func(childComplexity int, names []string) int
|
||||
}
|
||||
|
||||
Record struct {
|
||||
@ -234,6 +236,8 @@ type QueryResolver interface {
|
||||
ResolveNames(ctx context.Context, names []string) ([]*Record, error)
|
||||
GetAuctionsByIds(ctx context.Context, ids []string) ([]*Auction, error)
|
||||
GetParticipants(ctx context.Context) ([]*Participant, error)
|
||||
GetParticipantByAddress(ctx context.Context, cosmosAddress string) (*Participant, error)
|
||||
GetParticipantByNitroAddress(ctx context.Context, nitroAddress string) (*Participant, error)
|
||||
}
|
||||
|
||||
type executableSchema struct {
|
||||
@ -728,6 +732,30 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
||||
|
||||
return e.complexity.Query.GetBondsByIds(childComplexity, args["ids"].([]string)), true
|
||||
|
||||
case "Query.getParticipantByAddress":
|
||||
if e.complexity.Query.GetParticipantByAddress == nil {
|
||||
break
|
||||
}
|
||||
|
||||
args, err := ec.field_Query_getParticipantByAddress_args(context.TODO(), rawArgs)
|
||||
if err != nil {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
return e.complexity.Query.GetParticipantByAddress(childComplexity, args["cosmosAddress"].(string)), true
|
||||
|
||||
case "Query.getParticipantByNitroAddress":
|
||||
if e.complexity.Query.GetParticipantByNitroAddress == nil {
|
||||
break
|
||||
}
|
||||
|
||||
args, err := ec.field_Query_getParticipantByNitroAddress_args(context.TODO(), rawArgs)
|
||||
if err != nil {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
return e.complexity.Query.GetParticipantByNitroAddress(childComplexity, args["nitroAddress"].(string)), true
|
||||
|
||||
case "Query.getParticipants":
|
||||
if e.complexity.Query.GetParticipants == nil {
|
||||
break
|
||||
@ -1128,6 +1156,36 @@ func (ec *executionContext) field_Query_getBondsByIds_args(ctx context.Context,
|
||||
return args, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Query_getParticipantByAddress_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
|
||||
var err error
|
||||
args := map[string]interface{}{}
|
||||
var arg0 string
|
||||
if tmp, ok := rawArgs["cosmosAddress"]; ok {
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cosmosAddress"))
|
||||
arg0, err = ec.unmarshalNString2string(ctx, tmp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
args["cosmosAddress"] = arg0
|
||||
return args, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Query_getParticipantByNitroAddress_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
|
||||
var err error
|
||||
args := map[string]interface{}{}
|
||||
var arg0 string
|
||||
if tmp, ok := rawArgs["nitroAddress"]; ok {
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nitroAddress"))
|
||||
arg0, err = ec.unmarshalNString2string(ctx, tmp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
args["nitroAddress"] = arg0
|
||||
return args, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Query_getRecordsByIds_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
|
||||
var err error
|
||||
args := map[string]interface{}{}
|
||||
@ -4951,6 +5009,136 @@ func (ec *executionContext) fieldContext_Query_getParticipants(ctx context.Conte
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Query_getParticipantByAddress(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_Query_getParticipantByAddress(ctx, field)
|
||||
if err != nil {
|
||||
return graphql.Null
|
||||
}
|
||||
ctx = graphql.WithFieldContext(ctx, fc)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
ec.Error(ctx, ec.Recover(ctx, r))
|
||||
ret = graphql.Null
|
||||
}
|
||||
}()
|
||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
||||
ctx = rctx // use context from middleware stack in children
|
||||
return ec.resolvers.Query().GetParticipantByAddress(rctx, fc.Args["cosmosAddress"].(string))
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
return graphql.Null
|
||||
}
|
||||
if resTmp == nil {
|
||||
if !graphql.HasFieldError(ctx, fc) {
|
||||
ec.Errorf(ctx, "must not be null")
|
||||
}
|
||||
return graphql.Null
|
||||
}
|
||||
res := resTmp.(*Participant)
|
||||
fc.Result = res
|
||||
return ec.marshalNParticipant2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐParticipant(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) fieldContext_Query_getParticipantByAddress(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
fc = &graphql.FieldContext{
|
||||
Object: "Query",
|
||||
Field: field,
|
||||
IsMethod: true,
|
||||
IsResolver: true,
|
||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||
switch field.Name {
|
||||
case "cosmosAddress":
|
||||
return ec.fieldContext_Participant_cosmosAddress(ctx, field)
|
||||
case "nitroAddress":
|
||||
return ec.fieldContext_Participant_nitroAddress(ctx, field)
|
||||
case "role":
|
||||
return ec.fieldContext_Participant_role(ctx, field)
|
||||
case "kycId":
|
||||
return ec.fieldContext_Participant_kycId(ctx, field)
|
||||
}
|
||||
return nil, fmt.Errorf("no field named %q was found under type Participant", 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_getParticipantByAddress_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
|
||||
ec.Error(ctx, err)
|
||||
return
|
||||
}
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Query_getParticipantByNitroAddress(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_Query_getParticipantByNitroAddress(ctx, field)
|
||||
if err != nil {
|
||||
return graphql.Null
|
||||
}
|
||||
ctx = graphql.WithFieldContext(ctx, fc)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
ec.Error(ctx, ec.Recover(ctx, r))
|
||||
ret = graphql.Null
|
||||
}
|
||||
}()
|
||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
||||
ctx = rctx // use context from middleware stack in children
|
||||
return ec.resolvers.Query().GetParticipantByNitroAddress(rctx, fc.Args["nitroAddress"].(string))
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
return graphql.Null
|
||||
}
|
||||
if resTmp == nil {
|
||||
if !graphql.HasFieldError(ctx, fc) {
|
||||
ec.Errorf(ctx, "must not be null")
|
||||
}
|
||||
return graphql.Null
|
||||
}
|
||||
res := resTmp.(*Participant)
|
||||
fc.Result = res
|
||||
return ec.marshalNParticipant2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐParticipant(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) fieldContext_Query_getParticipantByNitroAddress(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
fc = &graphql.FieldContext{
|
||||
Object: "Query",
|
||||
Field: field,
|
||||
IsMethod: true,
|
||||
IsResolver: true,
|
||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||
switch field.Name {
|
||||
case "cosmosAddress":
|
||||
return ec.fieldContext_Participant_cosmosAddress(ctx, field)
|
||||
case "nitroAddress":
|
||||
return ec.fieldContext_Participant_nitroAddress(ctx, field)
|
||||
case "role":
|
||||
return ec.fieldContext_Participant_role(ctx, field)
|
||||
case "kycId":
|
||||
return ec.fieldContext_Participant_kycId(ctx, field)
|
||||
}
|
||||
return nil, fmt.Errorf("no field named %q was found under type Participant", 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_getParticipantByNitroAddress_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
|
||||
ec.Error(ctx, err)
|
||||
return
|
||||
}
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_Query___type(ctx, field)
|
||||
if err != nil {
|
||||
@ -9247,6 +9435,52 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
|
||||
return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
|
||||
}
|
||||
|
||||
out.Concurrently(i, func() graphql.Marshaler {
|
||||
return rrm(innerCtx)
|
||||
})
|
||||
case "getParticipantByAddress":
|
||||
field := field
|
||||
|
||||
innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
ec.Error(ctx, ec.Recover(ctx, r))
|
||||
}
|
||||
}()
|
||||
res = ec._Query_getParticipantByAddress(ctx, field)
|
||||
if res == graphql.Null {
|
||||
atomic.AddUint32(&invalids, 1)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
rrm := func(ctx context.Context) graphql.Marshaler {
|
||||
return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
|
||||
}
|
||||
|
||||
out.Concurrently(i, func() graphql.Marshaler {
|
||||
return rrm(innerCtx)
|
||||
})
|
||||
case "getParticipantByNitroAddress":
|
||||
field := field
|
||||
|
||||
innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
ec.Error(ctx, ec.Recover(ctx, r))
|
||||
}
|
||||
}()
|
||||
res = ec._Query_getParticipantByNitroAddress(ctx, field)
|
||||
if res == graphql.Null {
|
||||
atomic.AddUint32(&invalids, 1)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
rrm := func(ctx context.Context) graphql.Marshaler {
|
||||
return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
|
||||
}
|
||||
|
||||
out.Concurrently(i, func() graphql.Marshaler {
|
||||
return rrm(innerCtx)
|
||||
})
|
||||
@ -10073,6 +10307,10 @@ func (ec *executionContext) marshalNNodeInfo2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlac
|
||||
return ec._NodeInfo(ctx, sel, v)
|
||||
}
|
||||
|
||||
func (ec *executionContext) marshalNParticipant2gitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐParticipant(ctx context.Context, sel ast.SelectionSet, v Participant) graphql.Marshaler {
|
||||
return ec._Participant(ctx, sel, &v)
|
||||
}
|
||||
|
||||
func (ec *executionContext) marshalNParticipant2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐParticipant(ctx context.Context, sel ast.SelectionSet, v []*Participant) graphql.Marshaler {
|
||||
ret := make(graphql.Array, len(v))
|
||||
var wg sync.WaitGroup
|
||||
@ -10111,6 +10349,16 @@ func (ec *executionContext) marshalNParticipant2ᚕᚖgitᚗvdbᚗtoᚋcercᚑio
|
||||
return ret
|
||||
}
|
||||
|
||||
func (ec *executionContext) marshalNParticipant2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐParticipant(ctx context.Context, sel ast.SelectionSet, v *Participant) graphql.Marshaler {
|
||||
if v == nil {
|
||||
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
|
||||
ec.Errorf(ctx, "the requested element is null which the schema does not allow")
|
||||
}
|
||||
return graphql.Null
|
||||
}
|
||||
return ec._Participant(ctx, sel, v)
|
||||
}
|
||||
|
||||
func (ec *executionContext) marshalNRecord2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐRecord(ctx context.Context, sel ast.SelectionSet, v []*Record) graphql.Marshaler {
|
||||
ret := make(graphql.Array, len(v))
|
||||
var wg sync.WaitGroup
|
||||
|
@ -380,3 +380,25 @@ func (q queryResolver) GetParticipants(ctx context.Context) ([]*Participant, err
|
||||
|
||||
return participants, nil
|
||||
}
|
||||
|
||||
func (q queryResolver) GetParticipantByAddress(ctx context.Context, cosmosAddress string) (*Participant, error) {
|
||||
onboardingQueryClient := onboardingTypes.NewQueryClient(q.ctx)
|
||||
participantResp, err := onboardingQueryClient.GetParticipantByAddress(ctx, &onboardingTypes.QueryGetParticipantByAddressRequest{CosmosAddress: cosmosAddress})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
p := participantResp.Participant
|
||||
participant := &Participant{
|
||||
CosmosAddress: p.CosmosAddress,
|
||||
NitroAddress: p.NitroAddress,
|
||||
Role: p.Role,
|
||||
KycID: p.KycId,
|
||||
}
|
||||
|
||||
return participant, nil
|
||||
}
|
||||
|
||||
func (q queryResolver) GetParticipantByNitroAddress(ctx context.Context, nitroAddress string) (*Participant, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ service Query {
|
||||
option (google.api.http).get = "/cerc/onboarding/v1/participants";
|
||||
}
|
||||
|
||||
// Participants queries Participants list by laconic address
|
||||
// Participants queries Participants list by cosmos address
|
||||
rpc GetParticipantByAddress(QueryGetParticipantByAddressRequest)
|
||||
returns (QueryGetParticipantByAddressResponse) {
|
||||
option (google.api.http).get = "/cerc/onboarding/v1/participants/{cosmos_address}";
|
||||
|
@ -383,7 +383,7 @@ const _ = grpc.SupportPackageIsVersion4
|
||||
type QueryClient interface {
|
||||
// Participants queries Participants list
|
||||
Participants(ctx context.Context, in *QueryParticipantsRequest, opts ...grpc.CallOption) (*QueryParticipantsResponse, error)
|
||||
// Participants queries Participants list by laconic address
|
||||
// Participants queries Participants list by cosmos address
|
||||
GetParticipantByAddress(ctx context.Context, in *QueryGetParticipantByAddressRequest, opts ...grpc.CallOption) (*QueryGetParticipantByAddressResponse, error)
|
||||
// Participants queries Participants list by nitro address
|
||||
GetParticipantByNitroAddress(ctx context.Context, in *QueryGetParticipantByNitroAddressRequest, opts ...grpc.CallOption) (*QueryGetParticipantByNitroAddressResponse, error)
|
||||
@ -428,7 +428,7 @@ func (c *queryClient) GetParticipantByNitroAddress(ctx context.Context, in *Quer
|
||||
type QueryServer interface {
|
||||
// Participants queries Participants list
|
||||
Participants(context.Context, *QueryParticipantsRequest) (*QueryParticipantsResponse, error)
|
||||
// Participants queries Participants list by laconic address
|
||||
// Participants queries Participants list by cosmos address
|
||||
GetParticipantByAddress(context.Context, *QueryGetParticipantByAddressRequest) (*QueryGetParticipantByAddressResponse, error)
|
||||
// Participants queries Participants list by nitro address
|
||||
GetParticipantByNitroAddress(context.Context, *QueryGetParticipantByNitroAddressRequest) (*QueryGetParticipantByNitroAddressResponse, error)
|
||||
|
Loading…
Reference in New Issue
Block a user