1

I have a query in React

const allQueries = await API.graphql(graphqlOperation(queries.listProcess));

Then in my queries.js I have it defined as so.

```export const listProcess = `query ListProcess(
  $filter: ModelProcessFilterInput
  $limit: Int
  $nextToken: String
) {
  listProcess(filter: $filter, limit: $limit, nextToken: $nextToken) {
    items {
      id
      routine {
        id
        key
      }
      event {
        eventId
        detailType
        source
        account
        time
        region
        resources
        detail
      }
      tasks {
        key
        title
        status
        processId
        context
        eventId
        message
        export
        error
        output
      }
      workers {
        id
        type
      }
      status
      context
    }
    nextToken
  }
}
`;```

When I go to query it I get this error in JS

locations: null

message: "Can't resolve value (/listProcesss/items[1]/tasks) : type mismatch error, expected type LIST"

path: Array(4)

0: "listProcesss"

1: "items" 2: 1 3: "tasks" length: 4

2
  • Does the command succeed when calling AppSync directly? If not, it might be an issue in your listProcesses resolver, in which case we'd need to know the VTL you're using to help you. Commented Oct 28, 2019 at 4:21
  • Do you mean from the AWS AppSync Directly? I think running the query directly works fine. I'm not sure on the VTL where would I find the info out? Commented Oct 28, 2019 at 15:03

2 Answers 2

3

This error happens when your DynamoDB data doesn't match the GraphQL schema.

When there is a MAP/Object in the data, when the GraphQL schema is set to expect a LIST/Array.

Sign up to request clarification or add additional context in comments.

Comments

1

For me, I had the response set as an array rather than an object for a custom query.

type Query {
  stripeGetCheckoutSession(sessionId: ID!): [StripeSession] @function(name: "StripeGetCheckoutSession-${env}")
}

Removed the array brackets from [StripeSession] to StripeSession

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.