Closed brendan-hall closed 3 years ago
Hey @brendan-hall, thanks for creating the ticket and sorry for the delay. Do you use this package with NextJS or with another framework?
We plan to make this package more agnostic in the near future, making it more extensible.
Any particular recommendation?
Solved in #67
In the function returned by
createApiHandler
any operations passed in are overridden by the original handlers defined for that api route. This makes it impossible to override behaviour cleanly.Example:
Set up the following for
/api/bigcommerce/cart
Expected Outcome: Any requests for current cart state (
GET /api/bigcommerce/cart
) return a 500 with no data, or other failure state. Actual Outcome: Requests continue to succeed as though no changes have been made.I believe the solution is to swap the merging order here: https://github.com/bigcommerce/storefront-data-hooks/blob/136a7e3e10502296cd8d90ff419fcc3b020eb5af/src/api/utils/create-api-handler.ts#L51