-
Notifications
You must be signed in to change notification settings - Fork 425
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
Expose the operation name from juniper_rocket::GraphQLRequest
#353
Conversation
Measuring the runtime of queries will only tell if there are slow queries. To find out which queries are slow you need the operation name. Getting the operation name was previously not possible from a Rocket request handler. This fixes that.
Codecov Report
@@ Coverage Diff @@
## master #353 +/- ##
==========================================
- Coverage 88.32% 86.37% -1.96%
==========================================
Files 103 105 +2
Lines 14922 15373 +451
==========================================
+ Hits 13180 13278 +98
- Misses 1742 2095 +353
Continue to review full report at Codecov.
|
Looks good. Two nits:
|
@theduke Done |
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.
Looks great! Please add an integration test for juniper and juniper_rocket to make sure we don't regress in the future.
juniper_rocket/src/lib.rs
Outdated
if reqs.len() == 1 { | ||
reqs.get(0).and_then(|req| req.operation_name()) | ||
} else { | ||
None |
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.
Wouldn't we want a list of operations for batch requests for the same usecase?
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.
Yeah that is true. Fixed in 168a763
Exact toolchain is |
The bug you are hitting is rust-lang/rust#59344. |
It seems a solution was recently merged. I'll give it another shot on the latest nightly. |
I have added an integration test now. I wasn't quite sure if it also made sense to test the path where there is no operation name provided. I decided to trust the typesystem 😊 Let me know if you would like that. |
Thanks! |
I ran into this issue recently when implementing performance performance
monitoring for an app using juniper-rocket.