Gatsby: Sort group by field values

Created on 17 Sep 2019  路  8Comments  路  Source: gatsbyjs/gatsby

I have a use case where I need to sort groups by fieldValue. Apparently there was a similar FR before #3684.

I can open a pull request too and will need some guidance.

not stale GraphQL

Most helpful comment

Any updates on this? I have the same requirement. Right now I'm sorting in JS from the component but it would be great if this could be done in GraphQL.

All 8 comments

Similar #7628

Hiya!

This issue has gone quiet. Spooky quiet. 馃懟

We get a lot of issues, so we currently close issues after 30 days of inactivity. It鈥檚 been at least 20 days since the last update here.

If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 馃挭馃挏

@universse Isn't it a duplicate of #7628 ?

I think there's a difference.

For eg, using the following query,

allData(sort: { fields: date, order: DESC }) {
  group(field: category) {
    fieldValue
    nodes {
      id
    }
  }
}

I would want the ability to sort the group by fieldValue. So I would get some things like allData.group = [{ fieldValue: 'group1'}, { fieldValue: 'group2'}, { fieldValue: 'group3'}, ...]. It's not possible to do this currently. This is similar to #3684, which was closed.

As for #7628, I think what the OP meant is that the nodes within each group do not follow the sort order specified in the query, which is { field: data, order: DESC } in the above eg.

Looking forward to this feature! We're currently sorting this outside graphql on our own.

Hiya!

This issue has gone quiet. Spooky quiet. 馃懟

We get a lot of issues, so we currently close issues after 30 days of inactivity. It鈥檚 been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 馃挭馃挏

Hiya!

This issue has gone quiet. Spooky quiet. 馃懟

We get a lot of issues, so we currently close issues after 30 days of inactivity. It鈥檚 been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 馃挭馃挏

Any updates on this? I have the same requirement. Right now I'm sorting in JS from the component but it would be great if this could be done in GraphQL.

Was this page helpful?
0 / 5 - 0 ratings