poap-xyz / poap.js

POAP implemetation in javascript
https://sdk.poap.tech/
MIT License
9 stars 8 forks source link

Allow nested orderBy objects #113

Closed reobin closed 4 months ago

reobin commented 5 months ago

Is your feature request related to a problem? Please describe.

Hey team! During the implementation of the feature to sort collections by number of drops, I had to use an orderBy that looked like this:

{
  orderBy: { collections_items_aggregate: { count: 'desc' } },
}

Unfortunately, I had to remove the use of the createOrderBy from the SDK because it only allowed 1 level. ({ key: value }).

Describe the solution you'd like

Allow both nested and not objects as the orderBy.

jm42 commented 5 months ago

You can use createOrderBy it like:

const variables: OrderByVariables = {
  orderBy: {
    collections_items_aggregate: createOrderBy('count', Order.DESC),
  },
}

The problem might be that the type OrderByVariables doesn't support nested objects. I made #114 to address that.

jm42 commented 4 months ago

Now after #115 it can be done as:

const variables: OrderByVariables = {
  orderBy: createOrderBy('collections_items_aggregate.count', Order.DESC),
}