Skip to content
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

Closed
OlegIlyenko opened this issue Jul 26, 2015 · 2 comments

Comments

@OlegIlyenko
Copy link
Member

No description provided.

@dlreeves
Copy link
Contributor

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

@OlegIlyenko
Copy link
Member Author

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.

dlreeves added a commit to dlreeves/sangria that referenced this issue Aug 23, 2015
…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.
dlreeves added a commit to dlreeves/sangria that referenced this issue Aug 23, 2015
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.
OlegIlyenko added a commit that referenced this issue Aug 23, 2015
#33 - Macro for parsing graphql documents at compile time
@OlegIlyenko OlegIlyenko added this to the v0.4.0 milestone Aug 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants