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.
You can use apollo graphql client. You'll have to store the schema and query in json files and use pojos and mappers to create the complete request dynamically.
Docs: https://www.apollographql.com/docs/android/essentials/get-started-java/