apollo-link-rest
apollo-link-rest copied to clipboard
Allow body passing for non-POST/PUT requests.
Allow an optional flag to enable passing body params with DELETE
and GET
. Yes, technically we shouldn't do it, but there are servers out there that don't follow the best practices, and since most systems will allow it any way, we should have a way to do it. My suggestion is simply another flag in configuration that toggles whether or not to support that (in fact maybe we could create a capabilities matrix for non-standard HTTP features if this is a longer list).
Once there we just need to change this line: https://github.com/apollographql/apollo-link-rest/blob/master/src/restLink.ts#L971
to be:
-1 === ['GET', 'DELETE'].indexOf(method) || allowNonStandardBodies
We can even add a warning to the dev builds that says "Warning you appear to be trying to pass a body to a delete or get operation, if this is intended you should switch on the allowNonStandardBodies
flag. Or we could replace the hardcoded: ['GET', 'DELETE']
with a overridable config so the users can decide which ones to support bodies for.
Join to previous. This is a very necessary feature.
+1 to this request. What's the latest on it? 😅
Any work around for this?
I'm slightly partial to allowing people to override the array of Verbs that have banned bodies, something like:
const link = new RestLink({
httpVerbsWithBannedBodies: ["GET", "DELETE"], // default
})
No work has been done that I'm aware of @Fvaco.
...any plans to do work around this?
I have no plans to work on this @OZhurbenko
If this is high value to you, I could see it as an option on the endpoint config, are you interested in providing a PR?