aws-amplify / amplify-category-api

The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development. This plugin provides functionality for the API category, allowing for the creation and management of GraphQL and REST based backends for your amplify project.
https://docs.amplify.aws/
Apache License 2.0
81 stars 71 forks source link

Client does not support multiple GSIs with the same partition key #2667

Open wavegate opened 1 week ago

wavegate commented 1 week ago

Environment information

System:
  OS: Windows 11 10.0.22631
  CPU: (24) x64 13th Gen Intel(R) Core(TM) i7-13700KF
  Memory: 43.29 GB / 63.86 GB
Binaries:
  Node: 20.10.0 - C:\Program Files\nodejs\node.EXE
  Yarn: undefined - undefined
  npm: 9.8.1 - ~\AppData\Roaming\npm\npm.CMD
  pnpm: undefined - undefined
NPM Packages:
  @aws-amplify/backend: 1.0.0
  @aws-amplify/backend-cli: 1.0.1
  aws-amplify: 6.3.4
  aws-cdk: 2.140.0
  aws-cdk-lib: 2.140.0
  typescript: 5.4.5
AWS environment variables:
  AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1
  AWS_SDK_LOAD_CONFIG = 1
  AWS_STS_REGIONAL_ENDPOINTS = regional
No CDK environment variables

Data packages

amplify-vite-react-template@0.0.0 C:\Users\ccfra\Documents\GitHub\residency-match
├─┬ @aws-amplify/backend-cli@1.0.1
│ └─┬ @aws-amplify/schema-generator@1.0.0
│   └── @aws-amplify/graphql-schema-generator@0.8.4
└─┬ @aws-amplify/backend@1.0.0
  └─┬ @aws-amplify/backend-data@1.0.0
    └── @aws-amplify/data-construct@1.8.1

Description

This is my model schema:

InterviewInvite: a
      .model({
        applicationYear: a.integer(),
        anonymous: a.boolean(),
        graduateType: a.enum(["US", "IMG"]),
        img: a.enum(["nonUSIMG", "USIMG"]),
        sortType: a.string().required(),
        inviteDateTime: a.datetime().required(),
        geographicPreference: a.boolean(),
        signal: a.boolean(),
        locationState: a.enum(["IS", "OOS"]),
        programId: a.id().required(),
        program: a.belongsTo("Program", "programId"),
        additionalComments: a.string(),
        medicalDegree: a.ref("MedicalDegree"),
        step1ScorePass: a.boolean(),
        step1Score: a.integer(),
        step2Score: a.string(),
        comlex1ScorePass: a.boolean(),
        comlex2Score: a.string(),
        visaRequired: a.boolean(),
        subI: a.boolean(),
        home: a.boolean(),
        yearOfGraduation: a.integer(),
        greenCard: a.boolean(),
        away: a.boolean(),
        institutionName: a.string(),
        institutionNameLowerCase: a.string(),
        userProfileId: a.id(),
        userProfile: a.belongsTo("UserProfile", "userProfileId"),
      })
      .secondaryIndexes((index) => [
        index("sortType").sortKeys([
          "institutionNameLowerCase",
          "inviteDateTime",
        ]),
        index("sortType").sortKeys(["inviteDateTime"]),
        index("programId"),
      ])
      .authorization((allow) => [
        allow.publicApiKey().to(["read"]),
        allow.group("Admin"),
        allow.group("Moderator"),
        allow.owner(),
      ]),

Then, in frontend code, inspect the model and find that only the first GSI list operation is available:

console.log(client.models.InterviewInvite);

image

chrisbonifacio commented 1 week ago

Hi @wavegate thank you for raising this issue. I was able to reproduce it consistently with the provided repro steps and schema, so I've marked this as a bug for the team to investigate further.