//
// Copyright 2021 Vulcanize, Inc.
//

import assert from 'assert';
import debug from 'debug';
import { GraphQLResolveInfo } from 'graphql';

import {
  gqlTotalQueryCount,
  gqlQueryCount,
  getResultState,
  IndexerInterface,
  GraphQLBigInt,
  GraphQLBigDecimal,
  BlockHeight,
  OrderDirection,
  jsonBigIntStringReplacer,
  EventWatcher,
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
  setGQLCacheHints
} from '@cerc-io/util';

import { Indexer } from './indexer';

import { Token } from './entity/Token';
import { PoolFactory } from './entity/PoolFactory';
import { Pool } from './entity/Pool';
import { Bucket } from './entity/Bucket';
import { Lend } from './entity/Lend';
import { Loan } from './entity/Loan';
import { Account } from './entity/Account';
import { LiquidationAuction } from './entity/LiquidationAuction';
import { ReserveAuction } from './entity/ReserveAuction';
import { LPTransferorList } from './entity/LPTransferorList';
import { LPAllowance } from './entity/LPAllowance';
import { LPAllowanceList } from './entity/LPAllowanceList';
import { AddCollateral } from './entity/AddCollateral';
import { AddQuoteToken } from './entity/AddQuoteToken';
import { AuctionSettle } from './entity/AuctionSettle';
import { BondWithdrawn } from './entity/BondWithdrawn';
import { BucketBankruptcy } from './entity/BucketBankruptcy';
import { BucketTake } from './entity/BucketTake';
import { BucketTakeLPAwarded } from './entity/BucketTakeLPAwarded';
import { DrawDebt } from './entity/DrawDebt';
import { Flashloan } from './entity/Flashloan';
import { Kick } from './entity/Kick';
import { LoanStamped } from './entity/LoanStamped';
import { MoveQuoteToken } from './entity/MoveQuoteToken';
import { RemoveCollateral } from './entity/RemoveCollateral';
import { RemoveQuoteToken } from './entity/RemoveQuoteToken';
import { RepayDebt } from './entity/RepayDebt';
import { ReserveAuctionKick } from './entity/ReserveAuctionKick';
import { ReserveAuctionTake } from './entity/ReserveAuctionTake';
import { ResetInterestRate } from './entity/ResetInterestRate';
import { Settle } from './entity/Settle';
import { Take } from './entity/Take';
import { TransferLP } from './entity/TransferLP';
import { UpdateInterestRate } from './entity/UpdateInterestRate';
import { Approval } from './entity/Approval';
import { ApprovalForAll } from './entity/ApprovalForAll';
import { MoveLiquidity } from './entity/MoveLiquidity';
import { Transfer } from './entity/Transfer';
import { PoolCreated } from './entity/PoolCreated';
import { AddCollateralNFT } from './entity/AddCollateralNFT';
import { AuctionNFTSettle } from './entity/AuctionNFTSettle';
import { DrawDebtNFT } from './entity/DrawDebtNFT';
import { MergeOrRemoveCollateralNFT } from './entity/MergeOrRemoveCollateralNFT';
import { Position } from './entity/Position';
import { PositionLend } from './entity/PositionLend';
import { Burn } from './entity/Burn';
import { MemorializePosition } from './entity/MemorializePosition';
import { Mint } from './entity/Mint';
import { RedeemPosition } from './entity/RedeemPosition';
import { GrantFund } from './entity/GrantFund';
import { DistributionPeriod } from './entity/DistributionPeriod';
import { Proposal } from './entity/Proposal';
import { ProposalParams } from './entity/ProposalParams';
import { DistributionPeriodVote } from './entity/DistributionPeriodVote';
import { ScreeningVote } from './entity/ScreeningVote';
import { FundingVote } from './entity/FundingVote';
import { FundedSlate } from './entity/FundedSlate';
import { DelegateRewardClaimed } from './entity/DelegateRewardClaimed';
import { FundTreasury } from './entity/FundTreasury';
import { FundedSlateUpdated } from './entity/FundedSlateUpdated';
import { ProposalCreated } from './entity/ProposalCreated';
import { ProposalExecuted } from './entity/ProposalExecuted';
import { DistributionPeriodStarted } from './entity/DistributionPeriodStarted';
import { VoteCast } from './entity/VoteCast';
import { DelegateChanged } from './entity/DelegateChanged';
import { DelegateVotesChanged } from './entity/DelegateVotesChanged';
import { BurnWrap } from './entity/BurnWrap';

const log = debug('vulcanize:resolver');

export const createResolvers = async (indexerArg: IndexerInterface, eventWatcher: EventWatcher): Promise<any> => {
  const indexer = indexerArg as Indexer;

  // eslint-disable-next-line @typescript-eslint/no-unused-vars
  const gqlCacheConfig = indexer.serverConfig.gqlCache;

  return {
    BigInt: GraphQLBigInt,

    BigDecimal: GraphQLBigDecimal,

    Event: {
      __resolveType: (obj: any) => {
        assert(obj.__typename);

        return obj.__typename;
      }
    },

    Subscription: {
      onEvent: {
        subscribe: () => eventWatcher.getEventIterator()
      }
    },

    Mutation: {
      watchContract: async (_: any, { address, kind, checkpoint, startingBlock = 1 }: { address: string, kind: string, checkpoint: boolean, startingBlock: number }): Promise<boolean> => {
        log('watchContract', address, kind, checkpoint, startingBlock);
        await indexer.watchContract(address, kind, checkpoint, startingBlock);

        return true;
      }
    },

    Query: {
      token: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('token', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('token').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(Token, id, block, info);
      },

      tokens: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('tokens', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('tokens').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          Token,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      poolFactory: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('poolFactory', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('poolFactory').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(PoolFactory, id, block, info);
      },

      poolFactories: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('poolFactories', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('poolFactories').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          PoolFactory,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      pool: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('pool', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('pool').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(Pool, id, block, info);
      },

      pools: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('pools', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('pools').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          Pool,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      bucket: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('bucket', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('bucket').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(Bucket, id, block, info);
      },

      buckets: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('buckets', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('buckets').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          Bucket,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      lend: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('lend', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('lend').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(Lend, id, block, info);
      },

      lends: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('lends', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('lends').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          Lend,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      loan: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('loan', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('loan').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(Loan, id, block, info);
      },

      loans: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('loans', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('loans').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          Loan,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      account: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('account', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('account').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(Account, id, block, info);
      },

      accounts: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('accounts', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('accounts').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          Account,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      liquidationAuction: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('liquidationAuction', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('liquidationAuction').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(LiquidationAuction, id, block, info);
      },

      liquidationAuctions: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('liquidationAuctions', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('liquidationAuctions').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          LiquidationAuction,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      reserveAuction: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('reserveAuction', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('reserveAuction').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(ReserveAuction, id, block, info);
      },

      reserveAuctions: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('reserveAuctions', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('reserveAuctions').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          ReserveAuction,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      lptransferorList: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('lptransferorList', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('lptransferorList').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(LPTransferorList, id, block, info);
      },

      lptransferorLists: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('lptransferorLists', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('lptransferorLists').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          LPTransferorList,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      lpallowance: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('lpallowance', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('lpallowance').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(LPAllowance, id, block, info);
      },

      lpallowances: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('lpallowances', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('lpallowances').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          LPAllowance,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      lpallowanceList: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('lpallowanceList', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('lpallowanceList').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(LPAllowanceList, id, block, info);
      },

      lpallowanceLists: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('lpallowanceLists', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('lpallowanceLists').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          LPAllowanceList,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      addCollateral: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('addCollateral', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('addCollateral').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(AddCollateral, id, block, info);
      },

      addCollaterals: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('addCollaterals', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('addCollaterals').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          AddCollateral,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      addQuoteToken: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('addQuoteToken', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('addQuoteToken').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(AddQuoteToken, id, block, info);
      },

      addQuoteTokens: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('addQuoteTokens', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('addQuoteTokens').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          AddQuoteToken,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      auctionSettle: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('auctionSettle', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('auctionSettle').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(AuctionSettle, id, block, info);
      },

      auctionSettles: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('auctionSettles', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('auctionSettles').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          AuctionSettle,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      bondWithdrawn: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('bondWithdrawn', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('bondWithdrawn').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(BondWithdrawn, id, block, info);
      },

      bondWithdrawns: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('bondWithdrawns', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('bondWithdrawns').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          BondWithdrawn,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      bucketBankruptcy: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('bucketBankruptcy', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('bucketBankruptcy').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(BucketBankruptcy, id, block, info);
      },

      bucketBankruptcies: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('bucketBankruptcies', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('bucketBankruptcies').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          BucketBankruptcy,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      bucketTake: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('bucketTake', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('bucketTake').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(BucketTake, id, block, info);
      },

      bucketTakes: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('bucketTakes', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('bucketTakes').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          BucketTake,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      bucketTakeLPAwarded: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('bucketTakeLPAwarded', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('bucketTakeLPAwarded').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(BucketTakeLPAwarded, id, block, info);
      },

      bucketTakeLPAwardeds: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('bucketTakeLPAwardeds', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('bucketTakeLPAwardeds').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          BucketTakeLPAwarded,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      drawDebt: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('drawDebt', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('drawDebt').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(DrawDebt, id, block, info);
      },

      drawDebts: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('drawDebts', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('drawDebts').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          DrawDebt,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      flashloan: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('flashloan', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('flashloan').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(Flashloan, id, block, info);
      },

      flashloans: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('flashloans', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('flashloans').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          Flashloan,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      kick: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('kick', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('kick').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(Kick, id, block, info);
      },

      kicks: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('kicks', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('kicks').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          Kick,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      loanStamped: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('loanStamped', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('loanStamped').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(LoanStamped, id, block, info);
      },

      loanStampeds: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('loanStampeds', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('loanStampeds').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          LoanStamped,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      moveQuoteToken: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('moveQuoteToken', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('moveQuoteToken').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(MoveQuoteToken, id, block, info);
      },

      moveQuoteTokens: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('moveQuoteTokens', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('moveQuoteTokens').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          MoveQuoteToken,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      removeCollateral: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('removeCollateral', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('removeCollateral').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(RemoveCollateral, id, block, info);
      },

      removeCollaterals: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('removeCollaterals', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('removeCollaterals').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          RemoveCollateral,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      removeQuoteToken: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('removeQuoteToken', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('removeQuoteToken').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(RemoveQuoteToken, id, block, info);
      },

      removeQuoteTokens: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('removeQuoteTokens', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('removeQuoteTokens').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          RemoveQuoteToken,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      repayDebt: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('repayDebt', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('repayDebt').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(RepayDebt, id, block, info);
      },

      repayDebts: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('repayDebts', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('repayDebts').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          RepayDebt,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      reserveAuctionKick: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('reserveAuctionKick', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('reserveAuctionKick').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(ReserveAuctionKick, id, block, info);
      },

      reserveAuctionKicks: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('reserveAuctionKicks', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('reserveAuctionKicks').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          ReserveAuctionKick,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      reserveAuctionTake: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('reserveAuctionTake', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('reserveAuctionTake').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(ReserveAuctionTake, id, block, info);
      },

      reserveAuctionTakes: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('reserveAuctionTakes', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('reserveAuctionTakes').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          ReserveAuctionTake,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      resetInterestRate: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('resetInterestRate', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('resetInterestRate').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(ResetInterestRate, id, block, info);
      },

      resetInterestRates: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('resetInterestRates', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('resetInterestRates').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          ResetInterestRate,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      settle: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('settle', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('settle').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(Settle, id, block, info);
      },

      settles: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('settles', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('settles').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          Settle,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      take: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('take', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('take').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(Take, id, block, info);
      },

      takes: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('takes', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('takes').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          Take,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      transferLP: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('transferLP', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('transferLP').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(TransferLP, id, block, info);
      },

      transferLPS: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('transferLPS', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('transferLPS').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          TransferLP,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      updateInterestRate: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('updateInterestRate', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('updateInterestRate').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(UpdateInterestRate, id, block, info);
      },

      updateInterestRates: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('updateInterestRates', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('updateInterestRates').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          UpdateInterestRate,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      approval: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('approval', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('approval').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(Approval, id, block, info);
      },

      approvals: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('approvals', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('approvals').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          Approval,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      approvalForAll: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('approvalForAll', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('approvalForAll').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(ApprovalForAll, id, block, info);
      },

      approvalForAlls: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('approvalForAlls', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('approvalForAlls').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          ApprovalForAll,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      moveLiquidity: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('moveLiquidity', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('moveLiquidity').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(MoveLiquidity, id, block, info);
      },

      moveLiquidities: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('moveLiquidities', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('moveLiquidities').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          MoveLiquidity,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      transfer: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('transfer', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('transfer').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(Transfer, id, block, info);
      },

      transfers: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('transfers', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('transfers').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          Transfer,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      poolCreated: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('poolCreated', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('poolCreated').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(PoolCreated, id, block, info);
      },

      poolCreateds: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('poolCreateds', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('poolCreateds').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          PoolCreated,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      addCollateralNFT: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('addCollateralNFT', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('addCollateralNFT').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(AddCollateralNFT, id, block, info);
      },

      addCollateralNFTS: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('addCollateralNFTS', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('addCollateralNFTS').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          AddCollateralNFT,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      auctionNFTSettle: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('auctionNFTSettle', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('auctionNFTSettle').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(AuctionNFTSettle, id, block, info);
      },

      auctionNFTSettles: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('auctionNFTSettles', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('auctionNFTSettles').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          AuctionNFTSettle,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      drawDebtNFT: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('drawDebtNFT', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('drawDebtNFT').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(DrawDebtNFT, id, block, info);
      },

      drawDebtNFTS: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('drawDebtNFTS', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('drawDebtNFTS').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          DrawDebtNFT,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      mergeOrRemoveCollateralNFT: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('mergeOrRemoveCollateralNFT', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('mergeOrRemoveCollateralNFT').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(MergeOrRemoveCollateralNFT, id, block, info);
      },

      mergeOrRemoveCollateralNFTS: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('mergeOrRemoveCollateralNFTS', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('mergeOrRemoveCollateralNFTS').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          MergeOrRemoveCollateralNFT,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      position: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('position', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('position').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(Position, id, block, info);
      },

      positions: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('positions', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('positions').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          Position,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      positionLend: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('positionLend', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('positionLend').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(PositionLend, id, block, info);
      },

      positionLends: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('positionLends', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('positionLends').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          PositionLend,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      burn: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('burn', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('burn').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(Burn, id, block, info);
      },

      burns: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('burns', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('burns').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          Burn,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      memorializePosition: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('memorializePosition', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('memorializePosition').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(MemorializePosition, id, block, info);
      },

      memorializePositions: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('memorializePositions', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('memorializePositions').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          MemorializePosition,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      mint: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('mint', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('mint').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(Mint, id, block, info);
      },

      mints: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('mints', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('mints').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          Mint,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      redeemPosition: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('redeemPosition', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('redeemPosition').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(RedeemPosition, id, block, info);
      },

      redeemPositions: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('redeemPositions', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('redeemPositions').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          RedeemPosition,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      grantFund: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('grantFund', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('grantFund').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(GrantFund, id, block, info);
      },

      grantFunds: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('grantFunds', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('grantFunds').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          GrantFund,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      distributionPeriod: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('distributionPeriod', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('distributionPeriod').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(DistributionPeriod, id, block, info);
      },

      distributionPeriods: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('distributionPeriods', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('distributionPeriods').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          DistributionPeriod,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      proposal: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('proposal', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('proposal').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(Proposal, id, block, info);
      },

      proposals: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('proposals', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('proposals').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          Proposal,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      proposalParams: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('proposalParams', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('proposalParams').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(ProposalParams, id, block, info);
      },

      proposalParamss: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('proposalParamss', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('proposalParamss').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          ProposalParams,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      distributionPeriodVote: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('distributionPeriodVote', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('distributionPeriodVote').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(DistributionPeriodVote, id, block, info);
      },

      distributionPeriodVotes: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('distributionPeriodVotes', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('distributionPeriodVotes').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          DistributionPeriodVote,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      screeningVote: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('screeningVote', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('screeningVote').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(ScreeningVote, id, block, info);
      },

      screeningVotes: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('screeningVotes', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('screeningVotes').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          ScreeningVote,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      fundingVote: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('fundingVote', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('fundingVote').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(FundingVote, id, block, info);
      },

      fundingVotes: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('fundingVotes', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('fundingVotes').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          FundingVote,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      fundedSlate: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('fundedSlate', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('fundedSlate').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(FundedSlate, id, block, info);
      },

      fundedSlates: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('fundedSlates', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('fundedSlates').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          FundedSlate,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      delegateRewardClaimed: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('delegateRewardClaimed', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('delegateRewardClaimed').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(DelegateRewardClaimed, id, block, info);
      },

      delegateRewardClaimeds: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('delegateRewardClaimeds', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('delegateRewardClaimeds').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          DelegateRewardClaimed,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      fundTreasury: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('fundTreasury', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('fundTreasury').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(FundTreasury, id, block, info);
      },

      fundTreasuries: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('fundTreasuries', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('fundTreasuries').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          FundTreasury,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      fundedSlateUpdated: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('fundedSlateUpdated', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('fundedSlateUpdated').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(FundedSlateUpdated, id, block, info);
      },

      fundedSlateUpdateds: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('fundedSlateUpdateds', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('fundedSlateUpdateds').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          FundedSlateUpdated,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      proposalCreated: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('proposalCreated', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('proposalCreated').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(ProposalCreated, id, block, info);
      },

      proposalCreateds: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('proposalCreateds', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('proposalCreateds').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          ProposalCreated,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      proposalExecuted: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('proposalExecuted', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('proposalExecuted').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(ProposalExecuted, id, block, info);
      },

      proposalExecuteds: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('proposalExecuteds', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('proposalExecuteds').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          ProposalExecuted,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      distributionPeriodStarted: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('distributionPeriodStarted', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('distributionPeriodStarted').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(DistributionPeriodStarted, id, block, info);
      },

      distributionPeriodStarteds: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('distributionPeriodStarteds', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('distributionPeriodStarteds').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          DistributionPeriodStarted,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      voteCast: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('voteCast', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('voteCast').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(VoteCast, id, block, info);
      },

      voteCasts: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('voteCasts', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('voteCasts').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          VoteCast,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      delegateChanged: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('delegateChanged', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('delegateChanged').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(DelegateChanged, id, block, info);
      },

      delegateChangeds: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('delegateChangeds', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('delegateChangeds').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          DelegateChanged,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      delegateVotesChanged: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('delegateVotesChanged', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('delegateVotesChanged').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(DelegateVotesChanged, id, block, info);
      },

      delegateVotesChangeds: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('delegateVotesChangeds', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('delegateVotesChangeds').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          DelegateVotesChanged,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      burnWrap: async (
        _: any,
        { id, block = {} }: { id: string, block: BlockHeight },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('burnWrap', id, JSON.stringify(block, jsonBigIntStringReplacer));
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('burnWrap').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntity(BurnWrap, id, block, info);
      },

      burnWraps: async (
        _: any,
        { block = {}, where, first, skip, orderBy, orderDirection }: { block: BlockHeight, where: { [key: string]: any }, first: number, skip: number, orderBy: string, orderDirection: OrderDirection },
        __: any,
        info: GraphQLResolveInfo
      ) => {
        log('burnWraps', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('burnWraps').inc(1);

        // Set cache-control hints
        // setGQLCacheHints(info, block, gqlCacheConfig);

        return indexer.getSubgraphEntities(
          BurnWrap,
          block,
          where,
          { limit: first, skip, orderBy, orderDirection },
          info
        );
      },

      events: async (_: any, { blockHash, contractAddress, name }: { blockHash: string, contractAddress: string, name?: string }) => {
        log('events', blockHash, contractAddress, name);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('events').inc(1);

        const block = await indexer.getBlockProgress(blockHash);
        if (!block || !block.isComplete) {
          throw new Error(`Block hash ${blockHash} number ${block?.blockNumber} not processed yet`);
        }

        const events = await indexer.getEventsByFilter(blockHash, contractAddress, name);
        return events.map(event => indexer.getResultEvent(event));
      },

      eventsInRange: async (_: any, { fromBlockNumber, toBlockNumber }: { fromBlockNumber: number, toBlockNumber: number }) => {
        log('eventsInRange', fromBlockNumber, toBlockNumber);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('eventsInRange').inc(1);

        const syncStatus = await indexer.getSyncStatus();

        if (!syncStatus) {
          throw new Error('No blocks processed yet');
        }

        if ((fromBlockNumber < syncStatus.initialIndexedBlockNumber) || (toBlockNumber > syncStatus.latestProcessedBlockNumber)) {
          throw new Error(`Block range should be between ${syncStatus.initialIndexedBlockNumber} and ${syncStatus.latestProcessedBlockNumber}`);
        }

        const events = await indexer.getEventsInRange(fromBlockNumber, toBlockNumber);
        return events.map(event => indexer.getResultEvent(event));
      },

      getStateByCID: async (_: any, { cid }: { cid: string }) => {
        log('getStateByCID', cid);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('getStateByCID').inc(1);

        const state = await indexer.getStateByCID(cid);

        return state && state.block.isComplete ? getResultState(state) : undefined;
      },

      getState: async (_: any, { blockHash, contractAddress, kind }: { blockHash: string, contractAddress: string, kind: string }) => {
        log('getState', blockHash, contractAddress, kind);
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('getState').inc(1);

        const state = await indexer.getPrevState(blockHash, contractAddress, kind);

        return state && state.block.isComplete ? getResultState(state) : undefined;
      },

      _meta: async (
        _: any,
        { block = {} }: { block: BlockHeight }
      ) => {
        log('_meta');
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('_meta').inc(1);

        return indexer.getMetaData(block);
      },

      getSyncStatus: async () => {
        log('getSyncStatus');
        gqlTotalQueryCount.inc(1);
        gqlQueryCount.labels('getSyncStatus').inc(1);

        return indexer.getSyncStatus();
      }
    }
  };
};
