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

types(v4/v5): upgrade populate request param to include nested object #452

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

XanderD99
Copy link
Contributor

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

Changes:

Added new unified types for populate parameters in Strapi v5 and v4 to support nested object population and advanced filtering, sorting, and field selections. These types improve maintainability and consistency across versions.

Strapi v5:

  • New StrapiV5RequestPopulateParams:
    A type alias for Pick<Strapi5RequestParams<T>, 'fields' | 'sort' | 'populate' | 'filters'> to define allowed keys for nested population parameters.

  • New StrapiV5RequestPopulateParam:
    Unified type for populate, supporting:

    • '*' for populating all relations.
    • Nested objects for advanced population with StrapiV5RequestPopulateParams support.
    • String paths like "field.subfield" or arrays of such paths.

Strapi v4:

  • New Strapi4RequestPopulateParams:
    Similar to v5, but tailored for Strapi4RequestParams<T>.

  • New Strapi4RequestPopulateParam:
    Similar functionality as the v5 version but applied to Strapi v4.

Why this change is needed:

  • Enhances type safety for populate usage across Strapi v4 and v5 implementations.
  • Improves developer experience by standardizing the structure of nested population parameters.
  • Simplifies handling of fields, sort, and filters in nested relations.

I tested it a bit in TS Playground and does seem to work as intended.


Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes (not applicable as this is a types-only update).

Copy link

netlify bot commented Dec 19, 2024

👷 Deploy request for nuxt-strapi-module pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 497bf82

@benjamincanac benjamincanac changed the title upgrade populate request param to include nested object types: upgrade populate request param to include nested object Dec 19, 2024
@benjamincanac benjamincanac changed the title types: upgrade populate request param to include nested object types(v4/v5): upgrade populate request param to include nested object Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant