storefront-remix-starter icon indicating copy to clipboard operation
storefront-remix-starter copied to clipboard

Update codegen to use "client" preset

Open michaelbromley opened this issue 1 year ago • 0 comments

Graphql codegen has a client preset plugin which has the following advantage over the current generic SDK plugin:

  • It "automatically" types the graphql operation, so it is explicit in where a particular gql document is actually being used in the app. Makes things more maintainable.
  • Less indirection in the API layer. You just pass the operation constant to a fetch function.

This task would involve:

  1. Installing the client preset per the docs
  2. Updating the codegen config
  3. In all the "providers" files, replace the gql template function with a graphql function call.
  4. Remove calls to the "sdk" object, and instead pass the query/mutation constants directly to the fetch wrapper.

michaelbromley avatar Sep 22 '23 10:09 michaelbromley