1

I have the following trivial structure.

Table Tasks with foreign key teamId. And Teams table with a name column.

I have a Relay compliant GraphQL and if I wanted to get the Tasks with the Teams I would do something like that.

{
  taskNodes {
    Tasks: nodes {
      id,
      description
      Team: teamByTeamId {
        name
      }
    }
  }
}

And if I wanted to sort by the task description

{
  taskNodes(orderBy: DESCRIPTION) {
    Tasks: nodes {
      id,
      description
      Team: teamByTeamId {
        name
      }
    }
  }
}

But I want to sort by the Team name column. How how could you do that in GraphQL?

1 Answer 1

1

It looks like your taskNodes field takes an orderBy argument in the form of an Enum. GraphQL doesn't have generic sort functionality--it's all done through arguments passed into the fields.

When you use GraphiQL, the interactive query explorer for GraphQL, it should tell you what the available options for orderBy are. If there isn't anything that looks like TEAM_NAME or similar, you'll need to ask your API developer to add a new option.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.