shopify-api-js
shopify-api-js copied to clipboard
Updated the REST & Graphql clients to allow for TypeScript typings, a…
WHY are these changes introduced?
Fixes issue #193 - Adding Typescript types for REST & Graphql API Clients.
WHAT is this pull request doing?
- Added Types for all API Endpoints (extracted from the documentation site) and added namespaces for each endpoint with their individual requests.
- Updated the http_client, graphql_client and rest_client to accept the use of Generics.
- Updated the documentation to explain how types can easily be added to any request.
- Updated Typescript version for the package (required) to make typescript path matching work for mixed types (i.e. path:
products/${number}
for Product.GetById) - Added a mergeQuery function that allows for merged Graphql queries, explained in the updated docs.
Type of change
- [ ] Patch: Bug (non-breaking change which fixes an issue)
- [x] Minor: New feature (non-breaking change which adds functionality)
- [ ] Major: Breaking change (fix or feature that would cause existing functionality to not work as expected)
Checklist
- [ ] I have added a changelog entry, prefixed by the type of change noted above
- [x] I have added/updated tests for this change
- [x] I have documented new APIs/updated the documentation for modified APIs (for public APIs)
I've completed the CLA, please re-run the checks.
Hi @FelixTellmann, thank you for contributing! On the surface this seems quite interesting, we will look into it in more depth to see if we want to merge it!
Thank you for looking further into it. Let me know if I can be of any assistance in this. I've had a further look into the existing types that have been added to the package recently for each of the API versions. Currently, the types that I extracted from the Shopify.dev documentation site were based on the 2022/01 version.
+1 to this PR
Having to manually cast the body
after the client returns the response is clunky, this goes a way into improving the DX around using the provided client library.
+1 we are also manually casting body everywhere
+1 for PR. This PR would rapidly increase the DevX. Casting body is a no go.