Calling a GraphQL query with Javascript Query and passing variables

I'm trying to:

  • Fetch a list of users (email, id)
  • Run a loop over that list to call a graphql query
  • The graphql query would need to consume variables from the javascript query

When I try triggering the GraphQL query and passing additionalScope for the variables, it doesn't seem to use the variables.

As a test, I removed the loop and I'm trying to just trigger for one user:

linkSupportMember2.trigger({
  additionalScope: {
    email: allMembers.data.email[5],
    userId: allMembers.data.id[5],
    userIdString: allMembers.data.id[5]
  },
  onSuccess: (queryResults) => {
    return queryResults;
  },
  onFailure: (error) => {
    return error;
  }
});

return linkSupportMember;

Hey @jonnilundy,

Triggering a query with additionalScope simply exposes a key-value pair that you can then reference within the query itself. In this case, that means referencing {{ email }}. You will need to add these within the variables section of your graph query key.

See a similar thread here