The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I am able to connect to GraphQL restapi with a variable name with space using a GraphQL query string by prefixing and suffixing the variable name with a \ (backslash) and 2 double quotes "".
name: "Custom Tag"
i.e. name: \""Custom Tags\"" => works successfuly escaping with the \ backslash and 2 double quotes ""
However a variable name GraphQL Query containing a "-" hypen or dash will not work and I need help troubleshooting.
name:"Custom - Tag2"
i.e. name:\""Custom - Tag2\"" => Does not work, because of the hypen and I don't know how to escape this?
Solved! Go to Solution.
Hi @wdrain ,
According to your description, in GraphQL, variable names cannot contain hyphens or dashes because they are not valid characters for identifiers.1 This is due to possible ambiguity in parsing, as hyphens may be interpreted as subtraction operators in many programming languages. If you need to keep hyphens in the value, you can try to do so, but the variable name itself should follow valid naming conventions.
{
customTag2: "Custom - Tag2"
}
Queries and Mutations | GraphQL
[question] why names cannot contain dash '-' · Issue #479 · graphql/graphql-spec · GitHub
Best regards,
Albert He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi @wdrain ,
According to your description, in GraphQL, variable names cannot contain hyphens or dashes because they are not valid characters for identifiers.1 This is due to possible ambiguity in parsing, as hyphens may be interpreted as subtraction operators in many programming languages. If you need to keep hyphens in the value, you can try to do so, but the variable name itself should follow valid naming conventions.
{
customTag2: "Custom - Tag2"
}
Queries and Mutations | GraphQL
[question] why names cannot contain dash '-' · Issue #479 · graphql/graphql-spec · GitHub
Best regards,
Albert He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly