Context:
- I want to create a GraphQL query template with different variables that I can replace with key/values from another dictionary
- I want to give JS/React this template and dictionary and be able to replace the variables in the template with the corresponding values in the dictionary
How would you recommend I do this?
One idea is to represent the GraphQL templates as txt files and use JS string interpolation.
query {
pets {
${some_replaceable_attribute}
${another_replaceable_attribute}
}
}
And have JS do all the token replacements.
Do you have any other suggestions on how I should do this?
Thank you!