aws-amplify / amplify-codegen

Amplify Codegen is a JavaScript toolkit library for frontend and mobile developers building Amplify applications.
Apache License 2.0
58 stars 59 forks source link

How to access index(GSI) with amplify API? #864

Open Frankat1578 opened 1 year ago

Frankat1578 commented 1 year ago

Hi, Is the a way I can query data with index, both Partition and Sort keys, using the GraphQL API in android? I have already pulled down the index into my local project and its inside my query schema. Also I am able to query and generate results in my AppSyncConsole. But am unable to use this inside my android project? Using the example below is the any way I can use the index in the android project query?

  id: ID!
  name: String! @index(name: "byNameAndPhoneNumber", sortKeyFields: ["phoneNumber"], queryField: "customerByNameAndPhone")
  phoneNumber: String
  accountRepresentativeID: ID! @index 

Any links or suggestion is welcome. Thanks

AnilMaktala commented 1 year ago

Hi @Frankat1578 👋 , Thank you for the question. can you please share the query you tried in AppSync console?

Frankat1578 commented 1 year ago

Hi @AnilMaktala, This is my index definition: id: ID! @index(name: "byEventTime", sortKeyFields:["EventTime"])

Below is the simple query I tried in AppSync .

query MyQueryEvent {
  eventByIdAndEventTime(id: "a6b8a147-cb02-4f14-8157-a8e75d6cce82", EventTime: {eq: "05:15"}) {
    nextToken
    startedAt
    items {
      EventName
      EventTime
      EventStatus
    }
  }
}
vsvinayak commented 1 year ago

@Frankat1578, were you able to find a solution ? I am also facing a similar situation.

mindgrub-medwards commented 9 months ago

I'm also looking for a solution to this...