Merge changes to implement postgraphile GraphQL queries #166

Merged
nikugogoi merged 29 commits from ng-watcher-queries-v4 into sharding 2022-06-08 06:34:08 +00:00
Showing only changes of commit c19cc5c44d - Show all commits

View File

@ -673,7 +673,9 @@ func (ecr *CIDRetriever) RetrieveHeaderAndTxCIDsByBlockNumber(blockNumber int64)
// https://github.com/go-gorm/gorm/issues/4083#issuecomment-778883283 // https://github.com/go-gorm/gorm/issues/4083#issuecomment-778883283
// Will use join for TransactionCids once preload for 1:N is supported. // Will use join for TransactionCids once preload for 1:N is supported.
err := ecr.gormDB.Preload("TransactionCids").Joins("IPLD").Find(&headerCIDs, "block_number = ?", blockNumber).Error err := ecr.gormDB.Preload("TransactionCids", func(tx *gorm.DB) *gorm.DB {
return tx.Select("cid", "tx_hash", "index", "src", "dst", "header_id")
}).Joins("IPLD").Find(&headerCIDs, "block_number = ?", blockNumber).Error
if err != nil { if err != nil {
log.Error("header cid retrieval error") log.Error("header cid retrieval error")
return nil, err return nil, err
@ -690,7 +692,9 @@ func (ecr *CIDRetriever) RetrieveHeaderAndTxCIDsByBlockHash(blockHash common.Has
// https://github.com/go-gorm/gorm/issues/4083#issuecomment-778883283 // https://github.com/go-gorm/gorm/issues/4083#issuecomment-778883283
// Will use join for TransactionCids once preload for 1:N is supported. // Will use join for TransactionCids once preload for 1:N is supported.
err := ecr.gormDB.Preload("TransactionCids").Joins("IPLD").First(&headerCID, "block_hash = ?", blockHash.String()).Error err := ecr.gormDB.Preload("TransactionCids", func(tx *gorm.DB) *gorm.DB {
return tx.Select("cid", "tx_hash", "index", "src", "dst", "header_id")
}).Joins("IPLD").First(&headerCID, "block_hash = ?", blockHash.String()).Error
if err != nil { if err != nil {
log.Error("header cid retrieval error") log.Error("header cid retrieval error")
return headerCID, err return headerCID, err