Skip to content

bug: Appsync graphql errors when including multiple fields in query #11843

Open
@Rohan0135

Description

@Rohan0135

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When running graphql queries via app sync against dynamodb, certain queries are showing inconsistent behaviour between localstack and aws.

For queries where we have defined one or more fields in the @key , we are getting unexpected errors.

When we have 2 fields (partition key and sort key) defined we encounter the following error:

"An error occurred (ValidationException) when calling the Query operation: KeyConditionExpressions must only contain one condition per key",

When we have 1 field (just partition key) defined we get :

sortDirection is not supported for List operations without a Sort key defined

Expected Behavior

We expect both queries to return results i.e. data from dynamodb as it does with aws

How are you starting LocalStack?

With a docker-compose file

Steps To Reproduce

How are you starting localstack (e.g., bin/localstack command, arguments, or docker-compose.yml)

docker run localstack/localstack

Amplify graphql schema:

type Order
  @model(
    timestamps: { createdAt: "created_at", updatedAt: "updated_at" }
    subscriptions: null
  )
  @key(name: "byRestaurantAndStatus",fields: ["restaurant_id","current_status"],queryField: "ordersByRestaurantAndStatus")
  @key(name: "byUser", fields: ["user_id"], queryField: "ordersByUser")

  ) {
  id: ID!
  user_id: ID
  restaurant_id: ID!
  current_status: String!
  total_price: Float!
  created_at: AWSDateTime!
  updated_at: AWSDateTime!
}

Query 1.

query OrdersByUser {
    ordersByUser(user_id: "<id>", limit: 10) {
        nextToken
        items {
            id
            user_id
            restaurant_id
            current_status
     }
}

Query 2.

ordersByRestaurantAndStatus(
        restaurant_id: "<id>"
        current_status: { eq: "<status>" }
        limit: 10
    ) {
        nextToken
        items {
            id
            user_id
            restaurant_id
            current_status
         }
}

Environment

- OS: MacOS 14.2.1
- LocalStack:
  LocalStack version: 3.8 
  LocalStack build git hash: 80b630c24f1a57a8bccac741a2e13b54f83e4c18

Anything else?

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions