-
Notifications
You must be signed in to change notification settings - Fork 122
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 POST/PUT/etc methods in Query operations to utilize a body. #173
Conversation
…tation operations.
Codecov Report
@@ Coverage Diff @@
## master #173 +/- ##
==========================================
+ Coverage 92.65% 92.91% +0.25%
==========================================
Files 2 2
Lines 395 395
Branches 117 116 -1
==========================================
+ Hits 366 367 +1
+ Misses 27 26 -1
Partials 2 2
Continue to review full report at Codecov.
|
@nderscore would you mind adding some unit-tests to make sure we don't break this in the future? Thanks! |
@fbartho No problem. I added a test to cover this usage. I also added a test for the error state for when no body input is provided, since I touched it and it was missing from coverage. Turns out, it was unreachable code when no args are passed to the query, so I fixed that as well. 😄 |
c43f794
to
30fcb92
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome. LGTM
This PR fixes my issue. I guess until it gets released I'll throw it on npm under |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woo!
Thanks @fbartho |
This PR resolves #154.
Since v0.5.0, POST and other "Mutation"-y HTTP methods (PUT, PATCH, etc) are now permitted in Query operations.
Currently, when a query is defined using the
@rest
directive to wrap a POST call which includes a body (eg:input
argument), the body is silently ignored, despite the request being made as otherwise expected.This is because a restriction is still in place which prevents them having a body added to the request unless they are part of a Mutation operation. If we're going to allow a POST request to be made from a Query, it makes sense to include support for a body, since in most cases, these requests need them. This PR relaxes that restriction, instead relying solely on the HTTP method to determine whether we should attempt to build a body for the request.