Jawad Ali
Jawad Ali

Reputation: 71

AWS Amplify GraphQl multiple indexes on schema for separate queries

I have a AWS Amplify GraphQl project. A react application. In schema I have a model named "UserEntry". I want to write couple of queries. Let me share the model/schema first.

type UserEntry @model
  @auth(rules: [
   { allow: owner }
  ]) {
  id: ID!
  puzzle_id: String
  game_data: GameData
  createdAt: AWSDateTime 
  status: GameStatus! @index(name: "byStatus", sortKeyFields: ["createdAt"])
}

Queries:

  1. Fetch latest userEntry based on status. (Note: It is working with current schema and model). Latest userEntry can be fetched based on sort by createdAt DESC.
  2. Fetch latest userEntry irrespective of status. Status can be (completed/in-progress).

What are the necessary changes are required so that we can manage both the queries? Do we need to add more indexes?

Upvotes: 0

Views: 61

Answers (0)

Related Questions