shopify-api-js icon indicating copy to clipboard operation
shopify-api-js copied to clipboard

Updated the REST & Graphql clients to allow for TypeScript typings, a…

Open FelixTellmann opened this issue 2 years ago • 6 comments

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)

FelixTellmann avatar Apr 02 '22 17:04 FelixTellmann

I've completed the CLA, please re-run the checks.

FelixTellmann avatar Apr 03 '22 10:04 FelixTellmann

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!

paulomarg avatar Apr 05 '22 13:04 paulomarg

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.

FelixTellmann avatar Apr 06 '22 18:04 FelixTellmann

+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.

nickradford avatar Jun 30 '22 19:06 nickradford

+1 we are also manually casting body everywhere

bkspace avatar Jul 20 '22 21:07 bkspace

+1 for PR. This PR would rapidly increase the DevX. Casting body is a no go.

zifahm avatar Aug 07 '22 18:08 zifahm