In GraphQL, every field and nested object can get its own set of dynamic variables. The variable type is declared in the schema, or on Voyager.
To use these variables, we need to:
1. Replace the static value in the query for $variableName : type
2. Declare $variableName as one of the variables accepted by the query
3. Pass variableName : value in the separate variables dictionary.
Supply Example:
The variable type as seen in Voyager has been circled in red, below.
query searchManyPart($q: [SupPartMatchQuery!]!) { supMultiMatch( queries: $q, currency: "GBP" country: "GBR" ) { hits parts { mpn sellers { company { name } offers { prices { convertedPrice quantity } } } } } }
{ "q":[ {'start': 0, 'limit': 1, 'mpn': 'ML-1220/F1AN'}, {'start': 0, 'limit': 1, 'mpn': 'ERJ-2RKF1003X'}, {'start': 0, 'limit': 1, 'mpn': 'EEE-FK1E101XP'}] }
Design example:
The variable type as seen in Voyager has been circled in red, below.
query getProjectBoM($projectId: ID!) { desProjectById(id: $projectId) { id name tasks { id name description status } } }
{ "projectId": "RGVzUH..." }
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article