From d20aec6d8432798c938a0bc121c536afd03839fa Mon Sep 17 00:00:00 2001 From: Darrell Warde Date: Fri, 18 Aug 2023 13:35:31 +0200 Subject: [PATCH] Update `@queryOptions` to `@limit` and add migration step --- .../pages/migration/v4-migration/index.adoc | 20 +++++++++++++++++++ .../reference/directives/default-values.adoc | 20 ++++++++----------- .../pages/reference/directives/index.adoc | 12 +++++------ 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/modules/ROOT/pages/migration/v4-migration/index.adoc b/modules/ROOT/pages/migration/v4-migration/index.adoc index 72044213..b9ebd3a0 100644 --- a/modules/ROOT/pages/migration/v4-migration/index.adoc +++ b/modules/ROOT/pages/migration/v4-migration/index.adoc @@ -161,6 +161,26 @@ However, if using TypeScript, the exported interface to implement these classes We have renamed a number of directives and their arguments, in order to make using `@neo4j/graphql` more intuitive. +=== `@queryOptions` removed and `limit` argument moved to `@limit` + +If you were using the `@queryOptions` directive to configure the default and max values for limiting the data returned by queries, for instance: + +[source, graphql, indent=0] +---- +type Record @queryOptions(limit: { default: 10, max: 100 }) { + id: ID! +} +---- + +This is now achieved by using the `@limit` directive: + +[source, graphql, indent=0] +---- +type Record @limit(default: 10, max: 100) { + id: ID! +} +---- + [populatedBy-migration] === `@callback` renamed to `@populatedBy` diff --git a/modules/ROOT/pages/reference/directives/default-values.adoc b/modules/ROOT/pages/reference/directives/default-values.adoc index 2620c009..1202ee12 100644 --- a/modules/ROOT/pages/reference/directives/default-values.adoc +++ b/modules/ROOT/pages/reference/directives/default-values.adoc @@ -74,27 +74,23 @@ type Movie { } ---- -[[type-definitions-default-values-queryoptions]] -== `@queryOptions` +[[type-definitions-default-values-limit]] +== `@limit` -The `@queryOptions` is to be used on nodes, where applied will inject values into a query such as the `limit`. +The `@limit` is to be used on nodes, where applied will inject values into a query such as the `limit`. === Definition [source, graphql, indent=0] ---- -"""The `@queryOptions` is to be used on nodes, where applied will inject values into a query such as the `limit`.""" -directive @queryOptions( - """If no limit argument is supplied on query will fallback to this value.""" - limit: { - default: Int - max: Int - } +"""The `@limit` is to be used on nodes, where applied will inject values into a query such as the `limit`.""" +directive @limit( + default: Int + max: Int ) on OBJECT ---- -=== Limit -Limit has 2 arguments: +The directive has two arguments: * `default` - If no `limit` argument is passed to the query, the default limit will be used. The query may still pass a higher or lower `limit`. * `max` - Defines the maximum limit to be passed to the query. If a higher value is passed, this will be used instead. If no `default` value is set, `max` will be used for queries without limit. diff --git a/modules/ROOT/pages/reference/directives/index.adoc b/modules/ROOT/pages/reference/directives/index.adoc index 6cd68052..c6b63314 100644 --- a/modules/ROOT/pages/reference/directives/index.adoc +++ b/modules/ROOT/pages/reference/directives/index.adoc @@ -66,6 +66,12 @@ The `@id` directive marks a field as the unique ID for an object type, and allow Reference: xref::reference/directives/autogeneration.adoc#type-definitions-autogeneration-id[`@id`] +== `@limit` + +The `@limit` is to be used on nodes, and when applied will inject values into Cypher `LIMIT` clauses. + +Reference: xref::reference/directives/default-values.adoc#type-definitions-default-values-limit[`@limit`] + == `@mutation` This directive is used to limit the availability of Mutation operations in the library. @@ -106,12 +112,6 @@ This directive is used to limit the availability of Query operations in the libr Reference: xref:reference/directives/schema-configuration/type-configuration.adoc#_query[`@query`] -== `@queryOptions` - -The `@queryOptions` is to be used on nodes, where applied will inject values into a query such as the `limit`. - -Reference: xref::reference/directives/default-values.adoc#type-definitions-default-values-queryoptions[`@queryOptions`] - == `@readonly` label:deprecated[] This directive is deprecated. See the xref:reference/directives/schema-configuration/field-configuration.adoc#_settable[`@settable`] directive.