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

Add SDK headers to SF API client#649

Merged
paulomarg merged 3 commits intomainfrom
add_storefront_client_headers
Jan 3, 2023
Merged

Add SDK headers to SF API client#649
paulomarg merged 3 commits intomainfrom
add_storefront_client_headers

Conversation

@paulomarg
Copy link
Copy Markdown
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 melissaluu December 21, 2022 18:17
@paulomarg paulomarg requested a review from a team as a code owner December 21, 2022 18:17
@paulomarg paulomarg force-pushed the add_storefront_client_headers branch from 93d1df0 to 5f63649 Compare December 21, 2022 18:17
Copy link
Copy Markdown
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.

Comment thread lib/clients/graphql/storefront_client.ts Outdated
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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?

Comment thread lib/types.ts
@paulomarg paulomarg force-pushed the add_storefront_client_headers branch from 899747f to 7a98b53 Compare January 3, 2023 18:50
@paulomarg paulomarg requested a review from melissaluu January 3, 2023 18:50
Copy link
Copy Markdown
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