Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate orderings string values #269

Closed
angeloashmore opened this issue Nov 23, 2022 · 1 comment
Closed

Deprecate orderings string values #269

angeloashmore opened this issue Nov 23, 2022 · 1 comment
Labels
enhancement New feature or request v7 Getting addressed or related to version 7 of the kit

Comments

@angeloashmore
Copy link
Member

angeloashmore commented Nov 23, 2022

Is your feature request related to a problem? Please describe.

The orderings option allows for sorting query results. The client currently accepts a string in the format expected by Prismic's Rest API or an object describing a sorting.

String:

{
  orderings: "[my.product.price desc]"
}

Object:

{
  orderings: [
    { field: "my.product.price", direction: "desc" }
  ]
}

The second option is clearer to read, is typed via TypeScript, and shows that multiple orderings can be provided (as a result of it being an array).

The first option is easy to write incorrectly, provides no compile-time checks, and requires learning a new syntax.

Describe the solution you'd like

Deprecate string values for the orderings option and only allow the object version.

Additionally, orderings currently accepts a single value or an array. The type should be changed to only accept an array.

Describe alternatives you've considered

None :)

Additional context

This request was prompted by this Prismic Community question: https://community.prismic.io/t/how-to-sort-prismic-data-by-name-or-any-other-field/11793

@angeloashmore angeloashmore added the enhancement New feature or request label Nov 23, 2022
@angeloashmore angeloashmore added the v7 Getting addressed or related to version 7 of the kit label Dec 27, 2022
lihbr added a commit that referenced this issue Apr 11, 2023
* chore: deprecate `orderings` string values, resolves #269

* fix: add warning for `string` and `string[]` `orderings` values

* test: remove unused `@ts-expect-error`

* fix: update message name

---------

Co-authored-by: lihbr <lihbr@users.noreply.github.com>
Co-authored-by: Angelo Ashmore <angeloashmore@users.noreply.github.com>
@lihbr
Copy link
Member

lihbr commented Apr 11, 2023

Closed in #279

@lihbr lihbr closed this as completed Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request v7 Getting addressed or related to version 7 of the kit
Projects
None yet
Development

No branches or pull requests

2 participants