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

MI-168: Use more specific type than autogenerated NormalPage in getTransformedPageData parameters #78

Conversation

tvhees
Copy link
Contributor

@tvhees tvhees commented Jan 30, 2025

This is a compile-time-only fix. Using the full NormalPage type risks breaking the build process if BigCommerce updates the graphql schema for that entity, even though the data we actually request and require has not changed shape.

This change narrows the expected type to what the getTransformedPageData function actually uses. It also removes the type declarations on test data in normal-page-data.ts as they aren't required. It's better to let Typescript infer whether the test data matches that required by the function being tested.

@tvhees tvhees requested a review from a team as a code owner January 30, 2025 06:27
path: string;
htmlBody: string;
name: string;
seo: SeoDetailsFragment;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we have the SeoDetailsFragments as a manual type too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jackmacaa the fragment type is generated from our actual request to bigcommerce, so it won't break things when unrelated types change on the schema.

Ideally we would use fragments for the page types as well but that's not how the GraphQL requests were architected and I wanted to avoid runtime changes (which modifications to the GraphQL requests would be!)

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah ye that makes sense.

@TheOrangePuff TheOrangePuff merged commit 70de390 into aligent:main Jan 31, 2025
0 of 4 checks passed
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.

3 participants