Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions modules/ROOT/pages/directives/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ Particularly useful for types that are not correctly pluralized or are non-Engli
| xref:/directives/schema-configuration/field-configuration.adoc#_settable[`@settable`]
| Sets the availability of fields on the `create` and `update` inputs.

| xref:/directives/schema-configuration/field-configuration.adoc#_sortable[`@sortable`]
| Sets the availability of sorting inputs for that field.

| xref:/directives/schema-configuration/field-configuration.adoc#_filterable[`@filterable`]
| Defines the filters generated for a field.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,71 @@ input ActorUpdateInput {

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


== `@sortable`

This directive sets the availability of the input fields for sorting.
It has a single argument:

* **byValue**: if disabled, this field is not available for sorting.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any default?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, defaults to true. I added this, but I've noticed we don't add the defaults in the other parameters of this page


=== Definition

[source, graphql, indent=0]
----
"""Instructs @neo4j/graphql to generate sorting inputs for this field."""
directive @sortable(byValue: Boolean! = true) on FIELD_DEFINITION
----

=== Usage

With this definition:

[source, graphql, indent=0]
----
type Movie @node {
title: String!
description: String! @sortable(byValue: false)
}
----

The following input type is generated for Movies:

[source, graphql, indent=0]
----
"""
Fields to sort Movies by. The order in which sorts are applied is not guaranteed when specifying many fields in one MovieSort object.
"""
input MovieSort {
title: SortDirection
}
----

Movies can be sorted by the title, but not by description:

This is valid:
[source, graphql, indent=0]
----
query {
movies(sort: {title: DESC}) {
title
}
}
----

This is not valid:
[source, graphql, indent=0]
----
query {
movies(sort: {description: DESC}) {
title
}
}
----


If no fields are sortable, the type `MovieSort` is not generated, and the `sort` input isn't available.

== `@filterable`

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