Search code examples
arraysreact-nativegraphqlaws-appsyncmutation

AppSync, pass array as an input argument with graphql-tag


I'm using appSync with react-native, I have a mutation defined in my schema like this:

Mutation Definition

And it works fine when I test the mutation in the query section

Test mutation

The problem is that I'm not sure how to represent that with graphql-tag, I cannot figure it out how to pass the argument.

This is the representation I got:

graphql-tag representation

This is how I call the mutation:

Call Mutaiton

And this is the query definition, where vitals is and array

Query definition

But the mutation does not execute, it rolls back. I only can see this:

Mutation execution

Anyone can help me out??

Thanks in advance


Solution

  • You have declared a variable $vitals but are not providing that key in variables. You are setting variables with variables: initValues.vitals where initValues.vitals is the array of inputs that you want. You need to change it to variables: initValues so vitals remains a top level key that GraphQL can then find and replace the $vitals variable with.

    Let me know if this fixes your issue.