I have a a graphql query that has a data node that requires all quotation marks to be escaped like so:
data: "{\"access_token\": \"SOME_TOKEN\"}".
However, in the program I am writing, SOME_TOKEN is dynamic and thus I need to use a variable to reference the access token. However, because the token is a string, it has quotation marks as part of the variable. I would usually do something like access_token_var.replace(""", "\") but because this is graphql-client, the entire thing is wrapped in a string.
I am getting the error Variable $access_token is declared by __anonymous__ but not used.
How can I escape the quotes that are included in the string variable?
Full query:
CREATE_AUTHENTICATION_MUTATION ||= <<-'GRAPHQL'
mutation($access_token: String!, $refresh_token: String!, $user_id: ID!, $created_at: Int!, $__created: Int!, $expires_in: Int!){
createUserAuthentication(input: {
name: "my_test",
data: "
{\"access_token\": $access_token, \"refresh_token\": $refresh_token, \"user_id\": $user_id, \"instance_url\": \"REDACTED\", \"created_at\": $created_at, \"__created\": $__created, \"token_type\": \"bearer\", \"expires_in\": $expires_in}"
}){
authenticationId
clientMutationId
}
}
GRAPHQL