From 58ac8c403061858760fadca27c50906a5fba9d23 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Tue, 27 Aug 2024 14:42:54 +0530 Subject: [PATCH] Remove unused attributes arg from queryBonds GQL API --- gql/cerc-io/laconicd/schema.graphql | 2 +- gql/generated.go | 39 +++-------------------------- gql/resolver.go | 2 +- 3 files changed, 6 insertions(+), 37 deletions(-) diff --git a/gql/cerc-io/laconicd/schema.graphql b/gql/cerc-io/laconicd/schema.graphql index 86431843..288ebe37 100644 --- a/gql/cerc-io/laconicd/schema.graphql +++ b/gql/cerc-io/laconicd/schema.graphql @@ -227,7 +227,7 @@ type Query { getBondsByIds(ids: [String!]): [Bond] # Query bonds. - queryBonds(attributes: [KeyValueInput!]): [Bond] + queryBonds: [Bond] # Query bonds by owner. queryBondsByOwner(ownerAddresses: [String!]): [OwnerBonds] diff --git a/gql/generated.go b/gql/generated.go index 564e94a0..a21c18a3 100644 --- a/gql/generated.go +++ b/gql/generated.go @@ -183,7 +183,7 @@ 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, attributes []*KeyValueInput) int + QueryBonds func(childComplexity int) int QueryBondsByOwner func(childComplexity int, ownerAddresses []string) int QueryRecords func(childComplexity int, attributes []*KeyValueInput, all *bool, limit *int, offset *int) int ResolveNames func(childComplexity int, names []string) int @@ -233,7 +233,7 @@ 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, attributes []*KeyValueInput) ([]*Bond, error) + QueryBonds(ctx context.Context) ([]*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, limit *int, offset *int) ([]*Record, error) @@ -844,12 +844,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - 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 + return e.complexity.Query.QueryBonds(childComplexity), true case "Query.queryBondsByOwner": if e.complexity.Query.QueryBondsByOwner == nil { @@ -1294,21 +1289,6 @@ 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{}{} @@ -4596,7 +4576,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, fc.Args["attributes"].([]*KeyValueInput)) + return ec.resolvers.Query().QueryBonds(rctx) }) if err != nil { ec.Error(ctx, err) @@ -4628,17 +4608,6 @@ 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 } diff --git a/gql/resolver.go b/gql/resolver.go index 7f7e1f01..f5aaf055 100644 --- a/gql/resolver.go +++ b/gql/resolver.go @@ -320,7 +320,7 @@ func (q *queryResolver) GetBond(ctx context.Context, id string) (*Bond, error) { return getGQLBond(bondResp.GetBond()) } -func (q queryResolver) QueryBonds(ctx context.Context, attributes []*KeyValueInput) ([]*Bond, error) { +func (q queryResolver) QueryBonds(ctx context.Context) ([]*Bond, error) { bondQueryClient := bondtypes.NewQueryClient(q.ctx) bonds, err := bondQueryClient.Bonds(context.Background(), &bondtypes.QueryBondsRequest{}) if err != nil {