StarpTech / apollo-datasource-http

Optimized JSON HTTP Data Source for Apollo Server
MIT License
73 stars 32 forks source link

Handling of application/*+json response content-type #16

Closed Inkdpixels closed 3 years ago

Inkdpixels commented 3 years ago

As of now this datasource strictly checks against the application/json http content-type header. This is perfectly fine for most applications, however some APIs respond with JSON content types, such as ...

in which case the Dataloader does not parse the response body. It would be great if this package could extend it's list or improve the detection via a RegExp to ensure all content-types that are JSON like are being parsed.

StarpTech commented 3 years ago

Hi, @Inkdpixels could you provide some examples? I'm not aware of any.

Inkdpixels commented 3 years ago

Hey @StarpTech - I do not have any public examples, but take for example the Mime-Type application/geo+json, it is an official mime type which APIs can use to indicate that the response is not only JSON, but structured in a way that was specified by the GeoJSON spec

https://geojson.org/ https://www.rfc-editor.org/rfc/rfc7946.html

There are loads of other json like mime types, see https://www.iana.org/assignments/media-types/media-types.xhtml

StarpTech commented 3 years ago

I see no value in adding it when no user has an issue. I also don't know any popular fetching library that takes care of it. I will close it. Feel free to reopen if you need to support this.