Skip to content

Commit c7205a3

Browse files
authored
Merge pull request #289 from neo4j/sortable-docs
Add missing docs about sortable directive
2 parents 46f1861 + cbae0cf commit c7205a3

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

modules/ROOT/pages/directives/index.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ Particularly useful for types that are not correctly pluralized or are non-Engli
9494
| xref:/directives/schema-configuration/field-configuration.adoc#_settable[`@settable`]
9595
| Sets the availability of fields on the `create` and `update` inputs.
9696

97+
| xref:/directives/schema-configuration/field-configuration.adoc#_sortable[`@sortable`]
98+
| Sets the availability of sorting inputs for that field.
99+
97100
| xref:/directives/schema-configuration/field-configuration.adoc#_filterable[`@filterable`]
98101
| Defines the filters generated for a field.
99102

modules/ROOT/pages/directives/schema-configuration/field-configuration.adoc

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,71 @@ input ActorUpdateInput {
398398

399399
This means `actedIn` can be updated on an update, but it is no longer available on `create` operations.
400400

401+
402+
== `@sortable`
403+
404+
This directive sets the availability of the input fields for sorting.
405+
It has a single argument:
406+
407+
* **byValue**: Defaults to true. If disabled, this field is not available for sorting.
408+
409+
=== Definition
410+
411+
[source, graphql, indent=0]
412+
----
413+
"""Instructs @neo4j/graphql to generate sorting inputs for this field."""
414+
directive @sortable(byValue: Boolean! = true) on FIELD_DEFINITION
415+
----
416+
417+
=== Usage
418+
419+
With this definition:
420+
421+
[source, graphql, indent=0]
422+
----
423+
type Movie @node {
424+
title: String!
425+
description: String! @sortable(byValue: false)
426+
}
427+
----
428+
429+
The following input type is generated for Movies:
430+
431+
[source, graphql, indent=0]
432+
----
433+
"""
434+
Fields to sort Movies by. The order in which sorts are applied is not guaranteed when specifying many fields in one MovieSort object.
435+
"""
436+
input MovieSort {
437+
title: SortDirection
438+
}
439+
----
440+
441+
Movies can be sorted by the title, but not by description:
442+
443+
This is valid:
444+
[source, graphql, indent=0]
445+
----
446+
query {
447+
movies(sort: {title: DESC}) {
448+
title
449+
}
450+
}
451+
----
452+
453+
This is not valid:
454+
[source, graphql, indent=0]
455+
----
456+
query {
457+
movies(sort: {description: DESC}) {
458+
title
459+
}
460+
}
461+
----
462+
463+
464+
If no fields are sortable, the type `MovieSort` is not generated, and the `sort` input isn't available.
465+
401466
== `@filterable`
402467

403468
This directive defines the filters generated for the field to which this directive is applied.

0 commit comments

Comments
 (0)