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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce ability to pre-parse Request's query #891
Conversation
LGTM馃憦馃徎, but there seems to be an issue that changes the execution order of the extension callbacks.
|
Huh, strange, maybe I changed something after refactoring... |
@sunli829 Ah it makes sense, I wanted to avoid boxing future so I just split it into parts but now the lifecycle of extension changes 馃槥 |
@sunli829 Hm looking back, it seems my idea is difficult to be implemented with current lifetime of extensions. |
Another way to allow create |
@sunli829 Since |
Yes, adding the |
@sunli829 I reworked my solution as per your suggestion. |
I don't think it's a big problem, usually there won't be a lot of |
I removed |
Oh ok, no problem. |
@@ -42,6 +44,9 @@ pub struct Request { | |||
/// Disable introspection queries for this request. | |||
#[serde(skip)] | |||
pub disable_introspection: bool, | |||
|
|||
#[serde(skip)] | |||
pub(crate) parsed_query: Option<ExecutableDocument>, |
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.
This change is actually breaking semver. Since code that would've had directly constructed this public struct would not compile anymore.
This struct should've been #[non_exhaustive]
imo. 馃
@sunli829 thoughts?
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.
Thanks a lot, I just realized this, so I created the async-graphql-v4
branch. 馃榿
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.
oh... that's really unfortunate
I don't think we should allow Request
to be constructed from fields in future.
It is just pain in ass to worry about compatibility
This would allow user to avoid parsing query himself in order to determine its semantics
@sunli829 This is a bit specialized use case that I found myself in need.
Right now it is difficult to determine type of operation to finalize query context (in our case it is selection of Database: whether to use replica or primary)
So I made this split which would allow to parse, check operation type and then finalize execution.
It does require our database connection to be customizable without mutable reference to
Data
which is inconvenient but can be worked around with almost zero overhead (which is better than we parse query twice 馃槃 )