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

Update core helpers to support accurate typing for transformed models #691

Merged
merged 3 commits into from
Oct 9, 2024

Conversation

nima-ct
Copy link
Contributor

@nima-ct nima-ct commented Oct 7, 2024

Description

This PR upgrades type accuracy for list builder helpers by introducing a second type parameter for the transformed output model (either GraphQL or REST).

  • Previously, only the base model type was specified, representing the model from which the GraphQL or REST representations were derived. As a result, the returned data type did not accurately reflect the transformed output of these representations.

  • Now, by specifying both the base model type and the transformed output type, the returned data type precisely matches the actual structure of the GraphQL and REST responses.

  • For backward compatibility, the second type parameter will default to the base model (Model) if not provided.

  • Users should now explicitly provide the GraphqlModel when needed:

const graphqlList = buildGraphqlList<TDiscountCode, TDiscountCodeGraphql>(...)

@nima-ct nima-ct self-assigned this Oct 7, 2024
Copy link

changeset-bot bot commented Oct 7, 2024

🦋 Changeset detected

Latest commit: fb1824f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 46 packages
Name Type
@commercetools-test-data/core Patch
@commercetools-test-data/associate-role Patch
@commercetools-test-data/attribute-group Patch
@commercetools-test-data/business-unit Patch
@commercetools-test-data/cart-discount Patch
@commercetools-test-data/cart Patch
@commercetools-test-data/category Patch
@commercetools-test-data/channel Patch
@commercetools-test-data/commons Patch
@commercetools-test-data/custom-application Patch
@commercetools-test-data/custom-object Patch
@commercetools-test-data/custom-view Patch
@commercetools-test-data/customer-group Patch
@commercetools-test-data/customer Patch
@commercetools-test-data/customers-search-list-my-view Patch
@commercetools-test-data/discount-code Patch
@commercetools-test-data/discounts-custom-view Patch
@commercetools-test-data/filter-values Patch
@commercetools-test-data/inventory-entry Patch
@commercetools-test-data/order Patch
@commercetools-test-data/organization-extension Patch
@commercetools-test-data/organization Patch
@commercetools-test-data/payment Patch
@commercetools-test-data/platform-limits Patch
@commercetools-test-data/product-discount Patch
@commercetools-test-data/product-projection Patch
@commercetools-test-data/product-selection Patch
@commercetools-test-data/product-type Patch
@commercetools-test-data/product Patch
@commercetools-test-data/project-extension Patch
@commercetools-test-data/project Patch
@commercetools-test-data/quote-request Patch
@commercetools-test-data/quote Patch
@commercetools-test-data/review Patch
@commercetools-test-data/shipping-method Patch
@commercetools-test-data/shopping-list Patch
@commercetools-test-data/staged-quote Patch
@commercetools-test-data/standalone-price Patch
@commercetools-test-data/state Patch
@commercetools-test-data/store Patch
@commercetools-test-data/tax-category Patch
@commercetools-test-data/type Patch
@commercetools-test-data/user Patch
@commercetools-test-data/zone Patch
@commercetools-test-data/graphql-types Patch
@commercetools-test-data/utils Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@nima-ct nima-ct marked this pull request as ready for review October 7, 2024 12:50
@nima-ct nima-ct requested a review from a team as a code owner October 7, 2024 12:50
@nima-ct nima-ct requested review from CarlosCortizasCT and a team October 7, 2024 12:50
@nima-ct
Copy link
Contributor Author

nima-ct commented Oct 9, 2024

@emmenko @tdeekens any objections to these changes?

Copy link
Contributor

@tdeekens tdeekens left a comment

Choose a reason for hiding this comment

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

Thanks for the PR description and ping. This is a valuable improvement to how I can judge it.

@nima-ct nima-ct merged commit 1e2bba1 into main Oct 9, 2024
4 checks passed
@nima-ct nima-ct deleted the nj-build-helpers-fix branch October 9, 2024 11:19
@ct-changesets ct-changesets bot mentioned this pull request Oct 9, 2024
@CarlosCortizasCT
Copy link
Contributor

CarlosCortizasCT commented Oct 9, 2024

I'm sorry I didn't have the time to add my review before this PR has been merged, but I think this change does not goes in the direction of all the work we're doing in the FE Chapter towards specialized builders instead of general ones which gets transformed.

I'm not opposed to this change per se, as it does not conflict with that work, but it won't be necessary in the future.

It would be nice for the FE Chapter to be pinged with this kind of changes because of all the deep changes we're working on (reference).

@nima-ct
Copy link
Contributor Author

nima-ct commented Oct 9, 2024

I'm sorry I didn't have the time to add my review before this PR has been merged, but I think this change does not goes in the direction of all the work we're doing in the FE Chapter towards specialized builders instead of general ones which gets transformed.

I'm not opposed to this change per se, as it does not conflict with that work, but it won't be necessary in the future.

It would be nice for the FE Chapter to be pinged with this kind of changes because of all the deep changes we're working on (reference).

Hey Carlos, that makes sense.

The changes came from a need I had while working on a new feature to resolve some type issues in one of my tests. However, if you believe these changes might cause issues or conflicts in the future, I’m open to reverting them. Let me know

@CarlosCortizasCT
Copy link
Contributor

I'm sorry I didn't have the time to add my review before this PR has been merged, but I think this change does not goes in the direction of all the work we're doing in the FE Chapter towards specialized builders instead of general ones which gets transformed.
I'm not opposed to this change per se, as it does not conflict with that work, but it won't be necessary in the future.
It would be nice for the FE Chapter to be pinged with this kind of changes because of all the deep changes we're working on (reference).

Hey Carlos, that makes sense.

The changes came from a need I had while working on a new feature to resolve some type issues in one of my tests. However, if you believe these changes might cause issues or conflicts in the future, I’m open to reverting them. Let me know

My concern is about adding more code related to what are not the "legacy" patterns to build data models, but I think it's ok to keep your change.

Thanks.

@tdeekens
Copy link
Contributor

tdeekens commented Oct 9, 2024

I'm not opposed to this change per se, as it does not conflict with that work, but it won't be necessary in the future.

This is why I approved it.

The changes came from a need I had while working on a new feature to resolve some type issues in one of my tests.

This is what I saw benefits in.

t would be nice for the FE Chapter to be pinged with this kind of changes because of all the deep changes we're working on

Agreed let's all inform each other better.

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.

4 participants