-
Notifications
You must be signed in to change notification settings - Fork 226
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
grapql
string context macro to create parsed document and verify query at compile time
#33
Comments
Not sure where this lands on your priorities, but I have been messing with this over the last couple days. It's been a while since I've done any Scala code, but I was able to get something that is able to parse a graphql document that is a literal string at compile time. If you are taking pull request I'll try to clean it up and send one your way |
Of course, I would appreciate this! Even if it's not perfect yet, we can improve over the time, but we already will have something functional to begin with. |
…ingContext that adds a graphql method. This allows you to use string interpolation to parse a string literal into a sangria.ast.Document. This is done via a simple macro that calls QueryParse.parse on the string literal pulled from the StringContext call. The majority of the code is in implementing the Liftable type class for all the ASTNodes. This requires quite a bit of boilerplate, but should be fine for now. Perhaps there is something available that implements this type class automatically for case classes? This macro allows us to parse the string literal at compile time. Compilation will fail if the string cannot be parsed.
This addresses issue sangria-graphql#33 by adding a LiteralGraphQLStringContext that adds a graphql method. This allows you to use string interpolation to parse a string literal into a sangria.ast.Document. This is done via a simple macro that calls QueryParse.parse on the string literal pulled from the StringContext call. The majority of the code is in implementing the Liftable type class for all the ASTNodes. This requires quite a bit of boilerplate, but should be fine for now. Perhaps there is something available that implements this type class automatically for case classes? This macro allows us to parse the string literal at compile time. Compilation will fail if the string cannot be parsed.
#33 - Macro for parsing graphql documents at compile time
No description provided.
The text was updated successfully, but these errors were encountered: