apollographql / apollographql/datasource-rest
Refine `Content-Type` negotiation
- Dominant language
- TypeScript
- Stars
- 48
- Forks
- 21
- PR merge metrics
- No merged PRs in 30d
Description
The `parseBody` function is only using `startsWith` and `endsWith` to figure the content type.
https://github.com/apollographql/datasource-rest/blob/5ac9b524b1227b018c522da1a4e53425d2b86024/src/RESTDataSource.ts#L288-L289
In most cases (`application/json`) this is fine. But for users depending on the `+json` condition, this breaks for cases like this one:
```
application/ld+json; charset=utf-8
```
Ref: https://github.com/apollographql/datasource-rest/discussions/228#discussioncomment-6401539
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in src/RESTDataSource.ts at the parseBody logic around lines 288-289. Reproduce negotiation with application/ld+json; charset=utf-8 and compare it with application/json. Done means +json content types with parameters are recognized correctly without breaking the existing application/json case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100