Skip to content

Commit

Permalink
Fix Hasura Count Aggregation Filter (refinedev#1378)
Browse files Browse the repository at this point in the history
* Update index.ts

Aggregation Filters patch
Aggregation Operation Spelling

* Update packages/hasura/src/index.ts

Co-authored-by: Ömer Faruk APLAK <[email protected]>
  • Loading branch information
narayanpromax and omeraplak committed Dec 28, 2021
1 parent 62dac1d commit c8cd6d4
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/hasura/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ const dataProvider = (client: GraphQLClient): DataProvider => {

const operation = metaData?.operation ?? resource;

const aggreateOperation = `${operation}_aggregate`;
const aggregateOperation = `${operation}_aggregate`;

const hasuraSortingType = `[${operation}_order_by!]`;
const hasuraFiltersType = `${operation}_bool_exp`;
Expand All @@ -160,16 +160,22 @@ const dataProvider = (client: GraphQLClient): DataProvider => {
},
},
{
operation: aggreateOperation,
operation: aggregateOperation,
fields: [{ aggregate: ["count"] }],
variables: {
where: {
value: hasuraFilters,
type: hasuraFiltersType,
},
},
},
]);

const result = await client.request(query, variables);

return {
data: result[operation],
total: result[aggreateOperation].aggregate.count,
total: result[aggregateOperation].aggregate.count,
};
},

Expand Down

0 comments on commit c8cd6d4

Please sign in to comment.