Last active
January 13, 2022 17:07
-
-
Save JoviDeCroock/fc24d57e15505137599879e1b9da821f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { gql } from "@urql/core" | |
export type Maybe<T> = T | null; | |
export type InputMaybe<T> = Maybe<T>; | |
export type Loan_Filter = { | |
closed?: InputMaybe<Scalars['Boolean']>; | |
closed_in?: InputMaybe<Array<Scalars['Boolean']>>; | |
closed_not?: InputMaybe<Scalars['Boolean']>; | |
closed_not_in?: InputMaybe<Array<Scalars['Boolean']>>; | |
}; | |
export type QueryLoansArgs = { | |
block?: InputMaybe<Block_Height>; | |
first?: InputMaybe<Scalars['Int']>; | |
orderBy?: InputMaybe<Loan_OrderBy>; | |
orderDirection?: InputMaybe<OrderDirection>; | |
skip?: InputMaybe<Scalars['Int']>; | |
subgraphError?: _SubgraphErrorPolicy_; | |
where?: InputMaybe<Loan_Filter>; | |
}; | |
const homepageQuery = gql` | |
query($where: Loan_Filter , $first: Int, $orderBy: String, $orderDirect: String) { | |
loans(where: $where, first: $first, orderBy: $orderBy, orderDirection: $orderDirection) { | |
${ALL_LOAN_PROPERTIES} | |
} | |
} | |
`; | |
export default async function subgraphLoans(): Promise<Loan[]> { | |
const whereFilter: Loan_Filter = { closed: false }; | |
const variables: QueryLoansArgs = { | |
where: whereFilter, | |
first: 20, | |
orderBy: Loan_OrderBy.CreatedAtTimestamp, | |
orderDirection: OrderDirection.Desc, | |
}; | |
const { | |
data: { loans }, | |
} = await nftBackedLoansClient.query<ExpectedReturnData, QueryLoansArgs>(homepageQuery, variables).toPromise(); | |
return loans; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment