Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetchBaseQuery: return nullon empty body for JSON. Add DevWarnings. #1699

Merged
merged 4 commits into from
Nov 12, 2021

Conversation

phryneas
Copy link
Member

@phryneas phryneas commented Nov 6, 2021

Just something I wanted to do for a while.

@github-actions
Copy link

github-actions bot commented Nov 6, 2021

size-limit report 📦

Path Size
1. entry point: @reduxjs/toolkit (cjs.production.min.js) 12.88 KB (0%)
1. entry point: @reduxjs/toolkit (esm.js) 10.76 KB (0%)
1. entry point: @reduxjs/toolkit/query (cjs.production.min.js) 22.51 KB (0%)
1. entry point: @reduxjs/toolkit/query (esm.js) 18.85 KB (+0.01% 🔺)
1. entry point: @reduxjs/toolkit/query/react (cjs.production.min.js) 24.63 KB (0%)
1. entry point: @reduxjs/toolkit/query/react (esm.js) 21.38 KB (+0.01% 🔺)
2. entry point: @reduxjs/toolkit (without dependencies) (cjs.production.min.js) 5.7 KB (0%)
2. entry point: @reduxjs/toolkit (without dependencies) (esm.js) 5.65 KB (0%)
2. entry point: @reduxjs/toolkit/query (without dependencies) (cjs.production.min.js) 9.99 KB (+0.01% 🔺)
2. entry point: @reduxjs/toolkit/query (without dependencies) (esm.js) 10.41 KB (+0.01% 🔺)
2. entry point: @reduxjs/toolkit/query/react (without dependencies) (cjs.production.min.js) 2.65 KB (0%)
2. entry point: @reduxjs/toolkit/query/react (without dependencies) (esm.js) 2.49 KB (0%)
3. createSlice (esm.js) 5.03 KB (0%)
3. createEntityAdapter (esm.js) 6.28 KB (0%)
3. configureStore (esm.js) 5.62 KB (0%)
3. createApi (esm.js) 17.06 KB (0%)
3. createApi (react) (esm.js) 19.64 KB (0%)
3. fetchBaseQuery (esm.js) 11.57 KB (0%)
3. setupListeners (esm.js) 10.39 KB (0%)
3. ApiProvider (esm.js) 18.48 KB (0%)

@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 6, 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 50cf1ef:

Sandbox Source
Vanilla Configuration
Vanilla Typescript Configuration
rsk-github-issues-example Configuration
@examples-query-react/basic Configuration
@examples-query-react/advanced Configuration

@phryneas phryneas changed the title add dev errors if queryFn returns a wrong shape fetchBaseQuery: return null instead of undefined on empty body for JSON. add dev errors if baseQuery/queryFn returns a wrong shape Nov 12, 2021
@@ -54,7 +54,7 @@ const handleResponse = async (

if (responseHandler === 'json') {
const text = await response.text()
return text.length ? JSON.parse(text) : undefined
return text.length ? JSON.parse(text) : null
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this is a almost-breaking change, but a very minor one.

It is necessary as we cannot serialize undefined when transferring data from server to client in SSR scenarios.

@phryneas phryneas changed the title fetchBaseQuery: return null instead of undefined on empty body for JSON. add dev errors if baseQuery/queryFn returns a wrong shape fetchBaseQuery: return nullon empty body for JSON. Add DevWarnings. Nov 12, 2021
@phryneas phryneas merged commit b208e63 into v1.7.0-integration Nov 12, 2021
@phryneas phryneas deleted the queryFn-dev-erros branch November 12, 2021 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant