`@sort` directive semantics
See original GitHub issueThis is a proposal for semantics of a @sort
directive. The directive can be used on any property field. It has a direction and optional rank, defined in the schema like this:
directive @sort(direction: String!, rank: Int) on FIELD
The @sort
with rank 0
is done first, and then the @sort
with rank 1
is used to resolve ties, and so on. If there’s only one @sort
, rank can be omitted. If there’s N
@sort
directives, they must take all ranks from 0
to N - 1
.
The @sort
directive can be used on fields that are not in the output.
Here’s an example usage:
{
Animal {
name @sort(direction: "ascending", rank: 0)
out_Animal_ParentOf {
name @sort(direction: "descending", rank: 1)
uuid @output(out_name: "parent_uuid")
}
}
}
The compiler frontend sees whether the provided @sort
directives completely determine the output ordering, and includes this information in the output_metadata.
Emitting should be easy to implement, as MATCH, SQL, and Cypher all suport ordering by multiple parameters. I’m not sure about Gremlin, because I couldn’t find anything in its documentation.
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (6 by maintainers)
Top GitHub Comments
Let’s use enums then:
Does the rest of the design sense? Thumbs up this comment if it looks good, so we can start building it.
=
is not allowed.Off-off-topic: If we’re changing the
@filter
front-end, might be worth thinking about how to expressOR
.