-
Notifications
You must be signed in to change notification settings - Fork 161
Debug auto-derived implementation doesn't display queries correctly #518
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
Comments
I'm not sure I understand. What is __QUERY_WORKAROUND in your example? The |
@tomhoule I think the problem is when the macro read from files, we need to use include! rather than reading the file and re-including it, because it will escape the \n |
I don't see that as a problem, since that code isn't meant to be readable by humans. The reason why the full string is included, at the time when this was done, was because As it is now, I don't think we should change the |
I think what I don't understand is the upsides of a custom |
Imagine you have code like so: let query = RepositoryWithPullRequests::build_query(variables);
debug!("Github GRAPHQL Query: {}", query);
debug!("Github GraphQL Query: {:#?}", DebugPrettyQuery(&query)); the first line wouldn't work (no Display impl), the second line output would be unreadable. This is code from another service where I am wrapping the query into a custom Struct where I implement Debug correctly |
The first line wouldn't work, but |
Yes, one option is to have two debug statements |
Since all fields are public, you could also have a wrapper around struct QueryBodyCustomDebug(QueryBody);
impl Debug for QueryBodyCustomDebug {
// ...
} |
That's what I did. My suggestion is to have a "readable Debug implementation" out of the box, rather than having people to reimplement it themselves. What's the benefit of having an unreadable implementation? This can also be achieved by modifying the codegen macro |
Could you add an example of the current debug output and your suggested output to make the discussion easier? |
If you have a query saved in a graphql file on disk, it is likely to be correctly formatted and contain newlines
the problem with this is that the Debug macro auto-derive will escape newline, using the Debug format unusable
The text was updated successfully, but these errors were encountered: