Skip to content

Commit

Permalink
fix: re-introduce paramsSerializer (#408)
Browse files Browse the repository at this point in the history
We reintroduce the `paramsSerializer` (again) after removing it
[here](#370).

This is to unblock [the axios bump in
contentful-merge](contentful/contentful-merge#462)
or the skd-core bump [as
such](contentful/contentful-merge#552). We saw
that tests were failing because the query set together
[here](https://github.com/contentful/contentful-merge/blob/main/src/engine/create-changeset/tasks/create-fetch-partial-entities-task.ts#L43)
can not properly be handled by the API anymore and instead runs into

`error: InvalidQuery: The query you sent was invalid. Probably a filter
or ordering specification is not applicable to the type of a field.`

Tested locally on `contentful.js` and `contentful-merge`
  • Loading branch information
ruderngespra committed Nov 29, 2023
1 parent fd2345d commit 7103ccc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
"fast-copy": "^2.1.7",
"lodash.isplainobject": "^4.0.6",
"lodash.isstring": "^4.0.1",
"p-throttle": "^4.1.1"
"p-throttle": "^4.1.1",
"qs": "^6.11.2"
},
"devDependencies": {
"@babel/cli": "^7.12.8",
Expand All @@ -65,6 +66,7 @@
"@types/jest": "^29.2.2",
"@types/lodash.isplainobject": "^4.0.6",
"@types/lodash.isstring": "^4.0.6",
"@types/qs": "^6.9.10",
"@typescript-eslint/eslint-plugin": "^5.11.0",
"@typescript-eslint/parser": "^5.11.0",
"axios": "^1.6.0",
Expand Down
6 changes: 6 additions & 0 deletions src/create-http-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { AxiosRequestHeaders } from 'axios'
import type { AxiosStatic } from 'axios'
import copy from 'fast-copy'
import asyncToken from './async-token'
import qs from 'qs'

import rateLimitRetry from './rate-limit'
import rateLimitThrottle from './rate-limit-throttle'
Expand Down Expand Up @@ -94,6 +95,11 @@ export default function createHttpClient(
adapter: config.adapter,
maxContentLength: config.maxContentLength,
maxBodyLength: config.maxBodyLength,
paramsSerializer: {
serialize: (params) => {
return qs.stringify(params)
},
},
// Contentful
logHandler: config.logHandler,
responseLogger: config.responseLogger,
Expand Down

0 comments on commit 7103ccc

Please sign in to comment.