-
Notifications
You must be signed in to change notification settings - Fork 56
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
fix: Add support for operationName and variables in HTTP GET #3292
Conversation
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.
Some initial comments :)
http/handler_store.go
Outdated
operationNameFromQuery := req.URL.Query().Get("operationName") | ||
if operationNameFromQuery != "" { | ||
request.OperationName = operationNameFromQuery | ||
} |
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.
suggestion: You could assign directly to request.OperationName
. Doing so would have the exact same outcome as what you're doing here.
http/handler_store_test.go
Outdated
@@ -93,3 +94,79 @@ func TestExecRequest_WithInvalidQuery_HasSpecCompliantErrors(t *testing.T) { | |||
"message": "Cannot query field \"invalid\" on type \"User\".", | |||
}}) | |||
} | |||
|
|||
func TestExecRequest_WithValidQuery_HttpGet_WithOperationName_OmitsErrors(t *testing.T) { |
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.
suggestion: The test above that has WithValidQuery_OmitsErrors
, has this pattern because it specifically checks that with a valid query, the API returns no error field in the payload (we previously had an empty list for errors). I would suggestion removing WithValidQuery
as it's not that relevant to the test and instead of OmitsErrors
, maybe have something like ShouldSucceed
or something more meaningful. Same for the test bellow.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3292 +/- ##
========================================
Coverage 78.09% 78.09%
========================================
Files 382 382
Lines 35371 35383 +12
========================================
+ Hits 27621 27632 +11
Misses 6117 6117
- Partials 1633 1634 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 13 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
http/handler_store_test.go
Outdated
// errors should be omitted | ||
_, ok := gqlResponse["errors"] | ||
assert.False(t, ok) |
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.
suggestion: This could be removed as having it in the test suggests that it's important for this test to check that the errors are omitted (it's not). We have a dedicated test for this above.
http/handler_store_test.go
Outdated
// errors should be omitted | ||
_, ok := gqlResponse["errors"] | ||
assert.False(t, ok) |
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.
suggestion: Same as above.
http/handler_store_test.go
Outdated
_, ok := gqlResponse["errors"] | ||
assert.False(t, ok) | ||
|
||
// Compare the response data to the expected output |
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.
suggestion: This comment is describing what is already evident just by looking at the code. Was is less evident though is that you are ensuring that the returned user list doesn't include the _docID
field from the other operation. The comment should probably convey that.
http/handler_store_test.go
Outdated
_, ok := gqlResponse["errors"] | ||
assert.False(t, ok) | ||
|
||
// Compare the response data to the expected output |
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.
suggestion: Similar to above. In this case, something like Ensure only bob is returned based on the provided filter variable.
would be more descriptive.
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.
LGTM! Thanks for taking care of this, Chris :)
…etwork#3292) ## Relevant issue(s) Resolves sourcenetwork#3153 ## Description I have made it so that operationName and variables are supported by HTTP GET requests. I did this by modifying the `ExecRequest` function inside `http/handler_store.go` such that `operationName` and `variables` parameters are extracted if they are present. I added two new tests to `http/handler_store_test.go` which test this functionality. See: `TestExecRequest_WithValidQuery_HttpGet_WithOperationName_OmitsErrors` and `TestExecRequest_HttpGet_WithVariables_OmitsErrors` ## Tasks - [x] I made sure the code is well commented, particularly hard-to-understand areas. - [x] I made sure the repository-held documentation is changed accordingly. - [x] I made sure the pull request title adheres to the conventional commit style (the subset used in the project can be found in [tools/configs/chglog/config.yml](tools/configs/chglog/config.yml)). ## How has this been tested? The platform(s) on which this was tested: - Windows
Relevant issue(s)
Resolves #3153
Description
I have made it so that operationName and variables are supported by HTTP GET requests. I did this by modifying the
ExecRequest
function insidehttp/handler_store.go
such thatoperationName
andvariables
parameters are extracted if they are present.I added two new tests to
http/handler_store_test.go
which test this functionality. See:TestExecRequest_WithValidQuery_HttpGet_WithOperationName_OmitsErrors
and
TestExecRequest_HttpGet_WithVariables_OmitsErrors
Tasks
How has this been tested?
The platform(s) on which this was tested: