apollo-link-rest icon indicating copy to clipboard operation
apollo-link-rest copied to clipboard

Allow body passing for non-POST/PUT requests.

Open paulpdaniels opened this issue 4 years ago • 6 comments

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.

paulpdaniels avatar Sep 26 '19 08:09 paulpdaniels

Join to previous. This is a very necessary feature.

cudr avatar Nov 05 '19 12:11 cudr

+1 to this request. What's the latest on it? 😅

Fvaco avatar Jul 24 '20 09:07 Fvaco

Any work around for this?

esistgut avatar Jan 12 '21 14:01 esistgut

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.

fbartho avatar Jan 12 '21 22:01 fbartho

...any plans to do work around this?

OZhurbenko avatar Jan 19 '23 22:01 OZhurbenko

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?

fbartho avatar Jan 19 '23 23:01 fbartho