I have Graphql query in this format :
query {
priceData {
customer
id
title
dob
}
}
In java, we use this query in String format Like :
"{\"query\":\"query {\\r\\n priceData {\\r\\n customer \\r\\n id\\r\\n title\\r\\n dob\\r\\n }\\r\\n}\",\"variables\":{}}"
Here we hardcoded this query. Is there any other where we generate this query dynamically? Something like I create a POJO java class or Map type and later parse it to convert in GraphQL query string.
I am not really sure if there is any library that can help you with this, but I don't think so (only for the creation of the schema but that is a concern for the server not for you as the client). What you can actually do is store the String in a file and read it and store it in memory when your Java application starts. This way it would be easier to read and simpler to change if needed.