graphprotocol / graphprotocol/graph-node

Cannot Sort queries by enum

Open
#4,221 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

area/graphql enhancement Stale
Dominant language
Rust
Stars
3.2k
Forks
1.1k
Avg merge
4d 1h
Merged PRs (30d)
1

Description

Do you want to request a feature or report a bug?

Feature (maybe bug)

What is the current behavior?

When you make a query and try to sort on an enum you get an error.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.

What is the expected behavior?

Ideally we would want to be able to sort using an enum. I believe the issue is that enum Types create a custom type that can't be sorted in AssemblyScript, but they are almost always strings. I guess I would imagine it should be stored as a string (maybe) and then it would be able to be sorted on like that.

Against my point, if you made an enum numbers it wouldn't be totally accurate.

Moral of the story, it would be nice to sort on enums. Example query

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked GraphQL query and reproduce the failure when ordering positions by the enum field side. No files or tests are named in the issue, so trace the query's enum orderBy handling; done means enum fields can be used for sorting with defined behavior for string and numeric values.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, rust
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.