Shopify / shopify-api-js

Shopify Admin API Library for Node. Accelerate development with support for authentication, graphql proxy, webhooks
MIT License
943 stars 387 forks source link

Export lib/utils so the functions can be used by developers #716

Closed thesuavehog closed 1 year ago

thesuavehog commented 1 year ago

Overview/summary

There a useful functions in the lib/utils code which are not exported outside of creating a full Shopify client.

Namely:

It would be helpful to also export these directly instead of having to instantiate a full Shopify client in order to access them.

If lib just added export ShopifyUtils; it would be super helpful.

mkevinosullivan commented 1 year ago

@thesuavehog Can you provide a scenario where these would be needed without instantiating a Shopify client? For v6 of the library, we've intentionally tried to minimize exports to only those items needed by developers.

thesuavehog commented 1 year ago

This Shopify SDK seems designed with a priority on Express-type webserver applications. Specifically around Webhook handling. For webhooks handled by Lambda functions on AWS, the event handling flows are different and I'm not even sure if I can effectively use the Webhook code built into this SDK in that scenario.

I have written code to read the Webhook request and do the HMAC validation... but since safeCompare is used in the SDK, I have also used it in my code in order to try to make custom handling work the same as the SDK does (for HMAC validation).

I have replicated the code, but obviously it would be nicer to just call the built-in safeCompare that you already wrote and are maintaining to avoid extra maintenance or drift in the implementation.

Until the most recent release of this library, I also had to create my own customAppSession code (which uses those library functions listed in this ticket).

But in general, creating a full instance of the Shopify client in order to use a utility function costs CPU time and memory - which impacts the performance of code that is leveraging it.

I fully support the goals to provide as much Shopify functionality as possible in the core SDK, but you'll never cover everyone's esoteric scenarios. When there are building blocks of code used within the SDK which don't actually have any dependencies on the client itself, making those available would make it easier for developers to keep custom code working close to the internal workings of the library without having to synchronize their own copies of the building blocks to changes in the SDK itself.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 90 days with no activity. It will be closed if no further action occurs in 14 days.

github-actions[bot] commented 1 year ago

We are closing this issue because it has been inactive for a few months. This probably means that it is not reproducible or it has been fixed in a newer version. If it’s an enhancement and hasn’t been taken on since it was submitted, then it seems other issues have taken priority.

If you still encounter this issue with the latest stable version, please reopen using the issue template. You can also contribute directly by submitting a pull request– see the CONTRIBUTING.md file for guidelines

Thank you!