From e5f27c246c8bf66de8643568f5fac8ae2a8955c9 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Tue, 24 Sep 2024 12:34:39 +0530 Subject: [PATCH] Add funds released flag in GQL schema --- gql/cerc-io/laconicd/schema.graphql | 1 + gql/generated.go | 63 +++++++++++++++++++++++++++++ gql/models_gen.go | 1 + gql/util.go | 1 + 4 files changed, 66 insertions(+) diff --git a/gql/cerc-io/laconicd/schema.graphql b/gql/cerc-io/laconicd/schema.graphql index be9f857f..a58159c4 100644 --- a/gql/cerc-io/laconicd/schema.graphql +++ b/gql/cerc-io/laconicd/schema.graphql @@ -174,6 +174,7 @@ type Auction { maxPrice: Coin! # Max bid amount for service provider auction. kind: String! # Auction kind. numProviders: Int # Number of service providers + fundsReleased: Boolean! # Whether funds have been released to providers bids: [AuctionBid!]! # Bids made in the auction. } diff --git a/gql/generated.go b/gql/generated.go index 5ebb69a9..81225cfb 100644 --- a/gql/generated.go +++ b/gql/generated.go @@ -65,6 +65,7 @@ type ComplexityRoot struct { CommitFee func(childComplexity int) int CommitsEndTime func(childComplexity int) int CreateTime func(childComplexity int) int + FundsReleased func(childComplexity int) int ID func(childComplexity int) int Kind func(childComplexity int) int MaxPrice func(childComplexity int) int @@ -349,6 +350,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Auction.CreateTime(childComplexity), true + case "Auction.fundsReleased": + if e.complexity.Auction.FundsReleased == nil { + break + } + + return e.complexity.Auction.FundsReleased(childComplexity), true + case "Auction.id": if e.complexity.Auction.ID == nil { break @@ -2450,6 +2458,50 @@ func (ec *executionContext) fieldContext_Auction_numProviders(ctx context.Contex return fc, nil } +func (ec *executionContext) _Auction_fundsReleased(ctx context.Context, field graphql.CollectedField, obj *Auction) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Auction_fundsReleased(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 obj.FundsReleased, nil + }) + 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.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Auction_fundsReleased(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Auction", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _Auction_bids(ctx context.Context, field graphql.CollectedField, obj *Auction) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Auction_bids(ctx, field) if err != nil { @@ -3316,6 +3368,8 @@ func (ec *executionContext) fieldContext_AuthorityRecord_auction(ctx context.Con return ec.fieldContext_Auction_kind(ctx, field) case "numProviders": return ec.fieldContext_Auction_numProviders(ctx, field) + case "fundsReleased": + return ec.fieldContext_Auction_fundsReleased(ctx, field) case "bids": return ec.fieldContext_Auction_bids(ctx, field) } @@ -5309,6 +5363,8 @@ func (ec *executionContext) fieldContext_Query_getAuctionsByIds(ctx context.Cont return ec.fieldContext_Auction_kind(ctx, field) case "numProviders": return ec.fieldContext_Auction_numProviders(ctx, field) + case "fundsReleased": + return ec.fieldContext_Auction_fundsReleased(ctx, field) case "bids": return ec.fieldContext_Auction_bids(ctx, field) } @@ -8923,6 +8979,13 @@ func (ec *executionContext) _Auction(ctx context.Context, sel ast.SelectionSet, out.Values[i] = ec._Auction_numProviders(ctx, field, obj) + case "fundsReleased": + + out.Values[i] = ec._Auction_fundsReleased(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } case "bids": out.Values[i] = ec._Auction_bids(ctx, field, obj) diff --git a/gql/models_gen.go b/gql/models_gen.go index e8a62016..5afebccd 100644 --- a/gql/models_gen.go +++ b/gql/models_gen.go @@ -41,6 +41,7 @@ type Auction struct { MaxPrice *Coin `json:"maxPrice"` Kind string `json:"kind"` NumProviders *int `json:"numProviders"` + FundsReleased bool `json:"fundsReleased"` Bids []*AuctionBid `json:"bids"` } diff --git a/gql/util.go b/gql/util.go index bc295fc7..c8c70f09 100644 --- a/gql/util.go +++ b/gql/util.go @@ -250,6 +250,7 @@ func GetGQLAuction(auction *auctiontypes.Auction, bids []*auctiontypes.Bid) (*Au MaxPrice: getGQLCoin(auction.MaxPrice), Kind: auction.Kind, NumProviders: &numProviders, + FundsReleased: auction.FundsReleased, } auctionBids := make([]*AuctionBid, len(bids))