Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
justraman committed Jul 31, 2023
1 parent 3b389ec commit 5e04eeb
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/server-extension/resolvers/my_tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class MyTokensBestListing {
}

@ObjectType()
export class MyTokensResponse {
export class MyTokensToken {
@Field(() => ID)
id!: string

Expand Down Expand Up @@ -148,16 +148,27 @@ export class MyTokensResponse {
}
}

@ObjectType()
export class MyTokensResponse {
@Field(() => [MyTokensToken])
data!: MyTokensToken[]

@Field(() => Int)
count!: number

constructor(props: Partial<MyTokensResponse>) {
Object.assign(this, props)
}
}

@Resolver()
export class MyTokensResolver {
constructor(private tx: () => Promise<EntityManager>) {}

@Query(() => [MyTokensResponse])
async myTokens(@Args() { accountId, limit, offset, order, orderBy, query }: MyTokenArgs): Promise<MyTokensResponse[]> {
@Query(() => MyTokensResponse)
async myTokens(@Args() { accountId, limit, offset, order, orderBy, query }: MyTokenArgs): Promise<MyTokensResponse> {
const manager = await this.tx()

console.log(isValidAddress(accountId))

const builder = manager
.getRepository(Token)
.createQueryBuilder('token')
Expand All @@ -180,6 +191,8 @@ export class MyTokensResolver {
})
}

return builder.getMany() as any
const [data, count] = (await builder.getManyAndCount()) as any[]

return { data, count }
}
}

0 comments on commit 5e04eeb

Please sign in to comment.