[go: nahoru, domu]

Skip to content

How to use variables in graphql query via dgs java graphql client? #1944

Closed Answered by paulbakker
morohon asked this question in Q&A
Discussion options

You must be logged in to vote

Your question makes sense, but that's actually not supported with the codegen queries. The thinking is that if you're constructing your query in code like that, you can just pass in the variables there in the Java code.
The practical problem would be that the arguments in the codegen query are typed, so an Int is an Integer in Java, which also means you wouldn't be able to pass in a $myVar there.

I agree that it's a bit confusing that the codegen query API doesn't support variables, while the queryExecutor clearly does, but technically these APIs are completely separated.

If you, for some reason, need to use variables, I would recommend using a multiline String in Java/Kotlin and write th…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@morohon
Comment options

Answer selected by morohon
Comment options

You must be logged in to vote
1 reply
@morohon
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants