Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Add SDK headers to SF API client #649

Merged
merged 3 commits into from
Jan 3, 2023
Merged

Conversation

paulomarg
Copy link
Contributor

WHY are these changes introduced?

The Storefront API has been updated to allow a few headers to improve how we track requests to it, and our client should start complying with it.

WHAT is this pull request doing?

Making the override method where we set the headers for the GraphQL client more generic, so that it takes any number of headers, and setting the new headers in the SF API client.

Type of change

  • Patch: Bug (non-breaking change which fixes an issue)

Considering this a patch from the perspective of it being a fix for tracking, rather than adding new features for users of this library.

Checklist

  • I have added a changelog entry, prefixed by the type of change noted above
  • I have added/updated tests for this change

@paulomarg paulomarg requested a review from a team as a code owner December 21, 2022 18:17
Copy link
Contributor

@cquemin cquemin left a comment

Choose a reason for hiding this comment

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

Few minor questions regarding constant definition.

lib/clients/graphql/storefront_client.ts Outdated Show resolved Hide resolved
JSON = 'application/json', // eslint-disable-line @shopify/typescript/prefer-pascal-case-enums
GraphQL = 'application/graphql', // eslint-disable-line @shopify/typescript/prefer-pascal-case-enums
URLEncoded = 'application/x-www-form-urlencoded', // eslint-disable-line @shopify/typescript/prefer-pascal-case-enums
JSON = 'application/json',
Copy link
Contributor

Choose a reason for hiding this comment

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

Are they no Javascript constant we could use instead of defining them ourselves? I know it would not add much value but I am just cautious redefining things manually as it always open the door to a future mistake

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately no, we use @shopify/network for those shared constants. It has pre-defined values for the header names (which we use here), but not for the MIME types :(

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah ok I understand worth raising an issue there or even a PR no ? Or do you think thats not the right place for this sort of constant?

Copy link
Contributor

@melissaluu melissaluu left a comment

Choose a reason for hiding this comment

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

This looks good! Thanks for adding this 🚀

@paulomarg paulomarg merged commit c87f2ba into main Jan 3, 2023
@paulomarg paulomarg deleted the add_storefront_client_headers branch January 3, 2023 19:24
@shopify-shipit shopify-shipit bot temporarily deployed to production January 5, 2023 18:47 Inactive
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants