-
Notifications
You must be signed in to change notification settings - Fork 159
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
Support codegen from query string #470
Conversation
I don't have context on the change but that made me think, now that |
@tomhoule Oh! I didn't know that existed. I agree that would be a better way to include the query from a file. Do you know if that would still work with all the file path logic ( Seems like I could still make the changes to accept a query string instead of the file, right? |
For some early 👀 and any thoughts! @surma @nickwesselman @andrewhassan @adampetro |
The logic is different: the paths in the proc macro are relative to CARGO_MANIFEST_DIR, but To address the questions in the PR description
It should be backwards compatible at first, unless we decide to make the new attribute argument the only way, but progressively, deprecating the old argument.
The requirement is new to me, so I don't know. I haven''t looked too deep into your use case, but since this is done at compile time, maybe depending on the graphql_client_codegen crate directly would be easier, since it wouldn't involve the derive macro at all, and you can pass the string directly in there, so you probably wouldn't need to make any change to graphql_cilent. |
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.
Great stuff 🎉 Left some comments! Hope that’s helpful.
Would be great to also see a test for query_string
.
673017a
to
0e04dca
Compare
Ah, I removed the changes to |
Is this something we want to do? |
I can't speak for shopify, but I think that if I had more time to work on this crate, I'd like it to become more modular. The core value proposition is the codegen, and that's just a |
graphql-client/graphql_client_codegen/src/lib.rs Lines 5 to 7 in a7283cb
Sounds like we should align on a public interface for using the codegen crate directly, and then I can update this comment 😆 |
Oh, I guess we would replace the entire quoted |
Yes, that's what I had in mind. |
Add test for query string attribute Handle non-utf8 paths and files without extensions Co-authored-by: Surma <[email protected]> Update crate doc comment Use options: GraphQLClientCodegenOptions
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!
Context
Our crate generates the GraphQL query that uses the macro to generate Rust types. We want to avoid writing the generated query to a temporary file.
Proposal
graphql_client_codegen
and expose a function to generate module token stream from a query string (instead of a query path)generate_module_token_stream