Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Gen 2] Feature request: Support secondary index query with sorting #5048

Closed
1 of 14 tasks
hangoocn opened this issue Jun 23, 2024 · 3 comments
Closed
1 of 14 tasks

[Gen 2] Feature request: Support secondary index query with sorting #5048

hangoocn opened this issue Jun 23, 2024 · 3 comments
Labels
duplicate This issue or pull request already exists feature-request A request for a new feature or an enhancement to an existing API or category. GraphQL API Issues related to the API (GraphQL) Category pending-close-response-required The issue will be closed if details necessary to reproduce the issue are not provided within 7 days. pending-community-response Pending response from the issue opener or other community members

Comments

@hangoocn
Copy link

hangoocn commented Jun 23, 2024

Description

The flutter gen2 doc regarding secondary index query here uses typescript as example.

so the model is:

Message: a
    .model({
      roomId: a.id().required(),
      createdAt: a.datetime(),
    })
    .secondaryIndexes(index => [index('roomId').sortKeys(['createdAt']).queryField('listByDate')])
    .authorization(allow => [
      allow.owner(),
    ]),

After run client-code gen npx ampx generate graphql-client-code --app-id xxxx --branch main --format modelgen --model-target dart --out lib/models, I am not able to see listByDate function signature shown in the Message model's dart file, but I can only see the index created like below:

    modelSchemaDefinition.indexes = [
      amplify_core.ModelIndex(fields: const ["roomId", "createdAt"], name: "messagesByRoomIdAndCreatedAt")
    ];

I am not sure if sorting by secondary index is supported by flutter gen 2 or not, so created this feature request issue. What I want to do is the flutter way of await client.models.Message.listByDate({ roomId: "YOUR_ROOM_ID", }, { sortDirection: 'DESC', })

but there is no instrution on the doc what is the function call to execute the index query and with sorting

Categories

  • Analytics
  • API (REST)
  • API (GraphQL)
  • Auth
  • Authenticator
  • DataStore
  • Notifications (Push)
  • Storage

Steps to Reproduce

As mentioned above.

Screenshots

No response

Platforms

  • iOS
  • Android
  • Web
  • macOS
  • Windows
  • Linux

Flutter Version

3.19.3

Amplify Flutter Version

2.0.0

Deployment Method

Amplify CLI

Schema

@hangoocn hangoocn changed the title [Gen 2] Feature request: Support secondary index query [Gen 2] Feature request: Support secondary index query with sorting Jun 23, 2024
@tyllark
Copy link
Member

tyllark commented Jun 23, 2024

Hello @hangoocn thank you for submitting this issue. We will look into this and get back to you!

@tyllark tyllark added GraphQL API Issues related to the API (GraphQL) Category pending-triage This issue is in the backlog of issues to triage labels Jun 23, 2024
@Jordan-Nelson
Copy link
Member

@hangoocn thanks for opening the request. It looks like the linked docs are showing incorrect code samples. Those samples are for Amplify JS. We have made a note of the docs issue and will update it.

We do have a feature request tracking this. See #4942. The issue description and comments explain some current workarounds. If you would like to see this feature supported can you please give that issue a 👍 and leave a comment with your use case?

Let me know if you believe this request if different or have other questions.

@Jordan-Nelson Jordan-Nelson added duplicate This issue or pull request already exists feature-request A request for a new feature or an enhancement to an existing API or category. pending-close-response-required The issue will be closed if details necessary to reproduce the issue are not provided within 7 days. pending-community-response Pending response from the issue opener or other community members and removed pending-triage This issue is in the backlog of issues to triage labels Jun 25, 2024
@hangoocn
Copy link
Author

Hi @Jordan-Nelson Yes, it is same request and I have put 👍. I will close this one as duplicate. Thnx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists feature-request A request for a new feature or an enhancement to an existing API or category. GraphQL API Issues related to the API (GraphQL) Category pending-close-response-required The issue will be closed if details necessary to reproduce the issue are not provided within 7 days. pending-community-response Pending response from the issue opener or other community members
Projects
None yet
Development

No branches or pull requests

3 participants