question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`@sort` directive semantics

See original GitHub issue

This 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:open
  • Created 4 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
bojanserafimovcommented, Aug 30, 2019

Let’s use enums then:

enum Order {
    ASCENDING,
    DESCENDING,
}

Does the rest of the design sense? Thumbs up this comment if it looks good, so we can start building it.

1reaction
bojanserafimovcommented, Aug 30, 2019

Off-topic, but should we be thinking about switching to enums for filter operators as well? I’m not sure = and ones like it are allowed enum values, but maybe there is some opportunity that isn’t immediately obvious…

= is not allowed.

Off-off-topic: If we’re changing the @filter front-end, might be worth thinking about how to express OR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Concept Sort | Classroom Strategies - Reading Rockets
A concept sort is a vocabulary and comprehension strategy used to familiarize students with the vocabulary of a new topic or book.
Read more >
The SORT Statement (for SORT TABLE) - Micro Focus
The SORT statement creates a sort file by executing input procedures or by transferring records from another file, sorts the records in the...
Read more >
Word Sort - STRATEGIES
Students identify the meaning and properties of each word and then "sort" the list into collections of words with similar features. This "sorting"...
Read more >
ON THE LOGICAL-SEMANTIC STRUCTURE OF DIRECTIVES
The term "directive" (or "directive statement") is used here in a broad sense, comprising norms, commands, requests, ex- hortations, suggestions, advice ...
Read more >
Sort header - Angular Material
These headers should be contained within a parent element with the matSort directive, which will emit a matSortChange event when the user triggers...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found