I am working with a GraphQL query which has 1 parameter. I am calling this query from a JS query using the trigger function and additionalScope to send the parameter. The parameter value doesn’t make it into the query. I know the query works as I can hard code the parameter and data flows as expected.
Example query trigger used. The graphql query is named getPartner
.
getPartner.trigger({ additionalScope: { partnerId: 'hardCodedIdForTesting', }, onSuccess: function(pdata) { const editPartner = pdata.partners.partner; console.log('show me the data', editPartner); } })
In this example, pdata
is null as the query fails to run as there isn’t a partnerId value for it to use for its query.
In the graphql query, does anything need to be in the value side of the variable? In the Variables
section of the query on the left is the parameter, partnerId
, and on the right is left blank. I was assuming this is correct since this value is being passed in.
Please advise.
Hey @brettski, sorry for the late reply here but I want to makes sure this loose end is cleaned up for future users who get routed to the post.
Were you able to get this working? If possible, could you share a screenshot of the GraphQL query or another similar setup you were working on? Down in the variable section of the GraphQL query we would reference the partnerId. For example:
If we had a JS Query trigger this query with:
query4.trigger({
additionalScope: { firstQty: 25 }
});
We would get the first 25 customers in our Shopify Store.
Yes I was able to get this to work and I was and am using the same approach you show in your example above. It’s been two months so unfortunately I don’t recall what had transpired to get this working.
That’s totally reasonable- sorry again about that. Now that we’ve migrated the community I want to make sure we get everything tidied up for posterity!