Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Commit

Permalink
GraphQL Patch (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLoneRonin authored May 13, 2021
1 parent f521a94 commit 24050d9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@arweave/gateway",
"version": "0.9.0",
"version": "0.9.1",
"main": "dist/src/Gateway.js",
"repository": "[email protected]:ArweaveTeam/gateway.git",
"author": "Arweave <[email protected]>",
Expand Down
14 changes: 11 additions & 3 deletions src/graphql/query.graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ export async function generateQuery(params: QueryParams): Promise<QueryBuilder>

if (tags) {
const tagsConverted = tagToB64(tags);
const names: Array<string> = [];
const values: Array<string> = [];

const subQuery = connection
.queryBuilder()
Expand All @@ -93,17 +95,21 @@ export async function generateQuery(params: QueryParams): Promise<QueryBuilder>

if (tag.name === index) {
indexed = true;
query.orWhereIn(`transactions.${index}`, tag.values);
query.whereIn(`transactions.${index}`, tag.values);
}
}

if (indexed === false) {
subQuery.orWhere('name', tag.name);
subQuery.orWhereIn('value', tag.values);
names.push(tag.name);
values.push.apply(values, tag.values);

runSubQuery = true;
}
}

subQuery.whereIn('name', names);
subQuery.whereIn('value', values);

if (runSubQuery) {
const results = await subQuery
.limit(limit)
Expand Down Expand Up @@ -135,6 +141,8 @@ export async function generateQuery(params: QueryParams): Promise<QueryBuilder>
query.orderByRaw(orderByClauses[sortOrder]);
}

query.orderByRaw(`transactions.created_at DESC`);

return query;
}

Expand Down

0 comments on commit 24050d9

Please sign in to comment.