Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow body passing for non-POST/PUT requests. #230

Open
paulpdaniels opened this issue Sep 26, 2019 · 7 comments
Open

Allow body passing for non-POST/PUT requests. #230

paulpdaniels opened this issue Sep 26, 2019 · 7 comments

Comments

@paulpdaniels
Copy link
Contributor

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.

@cudr
Copy link

cudr commented Nov 5, 2019

Join to previous. This is a very necessary feature.

@Fvaco
Copy link

Fvaco commented Jul 24, 2020

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

@esistgut
Copy link

Any work around for this?

@fbartho
Copy link
Collaborator

fbartho commented Jan 12, 2021

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.

@OZhurbenko
Copy link

...any plans to do work around this?

@fbartho
Copy link
Collaborator

fbartho commented Jan 19, 2023

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?

@cargo-tim
Copy link

Is there any possibility to add this? I agree with the top comment that a body with a GET request is not best practice. However, I am needing to make a REST request to a server that does not follow best practices and which I don't have control over.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants