Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

Support a meta property on baseQuery, enhance fetchBaseQuery to pass through Request/Response clones #196

Merged
merged 6 commits into from
Apr 7, 2021

Conversation

msutkowski
Copy link
Member

@msutkowski msutkowski commented Apr 3, 2021

Closes #194

Overview
This PR allows a baseQueryFn to return a meta property that will pass through to transformResponse, onSuccess, and onError. fetchBaseQuery has been modified to pass through clones of the Request/Response.

Possible use cases

  • A user could merge the Response headers into the result payload
  • A user could pass-through properties from the Request and/or Response to an analytics or logging service in onError/onSuccess

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 3, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit a6558ae:

Sandbox Source
React Configuration
React Typescript Configuration
rtk-query-demo Configuration
svelte-app-rtk-simplequery-demo Configuration

@github-actions
Copy link

github-actions bot commented Apr 3, 2021

size-limit report 📦

Path Size
ESM full 10.12 KB (+0.51% 🔺)
ESM full (React) 11.44 KB (+0.43% 🔺)
createApi + setupListeners 9.14 KB (+0.17% 🔺)
createApi (React) + setupListeners 10.34 KB (+0.14% 🔺)
fetchBaseQuery 701 B (+6.06% 🔺)
retry 278 B (+2.59% 🔺)
ApiProvider 400 B (0%)
CJS minfied 15.66 KB (+0.46% 🔺)
CJS React minfied 17.26 KB (+0.41% 🔺)

@phryneas
Copy link
Collaborator

phryneas commented Apr 3, 2021

added a bit stuff on top of this :)

@msutkowski msutkowski changed the title WIP: inject response headers into transformResponse Support a meta property on baseQuery, enhance fetchBaseQuery to pass through Request/Response clones Apr 3, 2021
@phryneas
Copy link
Collaborator

phryneas commented Apr 3, 2021

We should probably merge #158 before this, since that deduplicates the query & mutation thunk logic.

@msutkowski msutkowski marked this pull request as ready for review April 3, 2021 18:35
@msutkowski msutkowski added the enhancement New feature or request label Apr 3, 2021
@msutkowski msutkowski added this to the 0.3.0 milestone Apr 3, 2021
@msutkowski msutkowski requested a review from phryneas April 7, 2021 03:26
@msutkowski
Copy link
Member Author

@phryneas Looks like I didn't break anything with the merge 🎉. Please just give it a once over :)

@phryneas
Copy link
Collaborator

phryneas commented Apr 7, 2021

Let's get this merged :)

@phryneas phryneas merged commit 65f9038 into next Apr 7, 2021
@phryneas phryneas deleted the feature/inject-headers-into-transformresponse branch April 7, 2021 16:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Would be great if there was a possibility to access the response headers
2 participants