amplify-category-api icon indicating copy to clipboard operation
amplify-category-api copied to clipboard

Secondary index with two sort key fields is unpopulated

Open jayKayEss opened this issue 2 years ago • 6 comments

Before opening, please confirm:

  • [X] I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
  • [X] I have searched for duplicate or closed issues.
  • [X] I have read the guide for submitting bug reports.
  • [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • [X] I have removed any sensitive information from my code snippets and submission.

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

16.3.0

Amplify CLI Version

8.3.1

What operating system are you using?

Mac

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No

Amplify Categories

api

Amplify Commands

push

Describe the bug

Given a GraphQL schema like this:

type Invoice {
  id: ID!
  buyer_paidol_id: ID!
    @index(
      name: "byBuyerPaidol"
      queryField: "invoicesByBuyerPaidol"
      sortKeyFields: ["date"]
    )
    @index(
      name: "byBuyerPaidolIdAndSupplierPaidolIdAndUserInvoiceId"
      queryField: "invoicesByBuyerPaidolIdAndSupplierPaidolIdAndUserInvoiceId"
      sortKeyFields: ["user_invoice_id", "supplier_paidol_id"]
    )
  supplier_paidol_id: ID!
  user_invoice_id: String!
}

The first index, byBuyerPaidol is populated and returns expected results in GQL. However, the second index, byBuyerPaidolIdAndSupplierPaidolIdAndUserInvoiceId is not populated:

image

Switching the order of sortKeyFields has no effect.

Expected behavior

The index should be populated.

Reproduction steps

  1. Edit schema
  2. Push

GraphQL schema(s)

type Invoice
  @model(subscriptions: { level: off })
  @auth(rules: [{ allow: private, operations: [read] }]) {
  id: ID!
  id_base58: String
  id_base58_short: String
  payment_file_queue_id: ID
    @index(
      name: "byPaymentFileQueue"
      queryField: "invoicesByPaymentFileQueue"
      sortKeyFields: ["createdAt"]
    )
  payment_file: PaymentFileQueue
    @hasOne(fields: ["payment_file_queue_id"])
    @auth(
      rules: [
        {
          allow: groups
          groupsField: "buyer_paidol_id"
          operations: [create, read, update, delete]
        }
      ]
    )
  buyer_paidol_id: ID!
    @index(
      name: "byBuyerPaidol"
      queryField: "invoicesByBuyerPaidol"
      sortKeyFields: ["date"]
    )
    @index(
      name: "byBuyerPaidolIdAndSupplierPaidolIdAndUserInvoiceId"
      queryField: "invoicesByBuyerPaidolIdAndSupplierPaidolIdAndUserInvoiceId"
      sortKeyFields: ["user_invoice_id", "supplier_paidol_id"]
    )
  paidol_vendor_id: ID!
  paidol_vendor: PaidolVendor!
    @hasOne(fields: ["paidol_vendor_id"])
    @auth(
      rules: [
        {
          allow: groups
          groupsField: "buyer_paidol_id"
          operations: [create, read, update, delete]
        }
      ]
    )
  supplier_paidol_id: ID!
  supplier_paidol: Paidol!
    @hasOne(fields: ["supplier_paidol_id"])
    @auth(
      rules: [
        {
          allow: groups
          groupsField: "buyer_paidol_id"
          operations: [create, read, update, delete]
        }
      ]
    )
  user_invoice_id: String!
    @auth(
      rules: [
        {
          allow: groups
          groupsField: "buyer_paidol_id"
          operations: [create, read, update, delete]
        }
      ]
    )
  date: AWSDateTime!
    @auth(
      rules: [
        {
          allow: groups
          groupsField: "buyer_paidol_id"
          operations: [create, read, update, delete]
        }
      ]
    )
  balance_due: Currency!
    @auth(
      rules: [
        {
          allow: groups
          groupsField: "buyer_paidol_id"
          operations: [create, read, update, delete]
        }
      ]
    )
  createdAt: AWSDateTime!
  transaction_id: String
    @auth(
      rules: [
        {
          allow: groups
          groupsField: "buyer_paidol_id"
          operations: [create, read, update, delete]
        }
      ]
    )
  priority_payment_id: String
    @auth(
      rules: [
        {
          allow: groups
          groupsField: "buyer_paidol_id"
          operations: [create, read, update, delete]
        }
      ]
    )
  priority_payment_status: String
    @auth(
      rules: [
        {
          allow: groups
          groupsField: "buyer_paidol_id"
          operations: [create, read, update, delete]
        }
      ]
    )
  priority_payment_type: String
    @auth(
      rules: [
        {
          allow: groups
          groupsField: "buyer_paidol_id"
          operations: [create, read, update, delete]
        }
      ]
    )
  priority_payment_date: AWSDateTime
    @auth(
      rules: [
        {
          allow: groups
          groupsField: "buyer_paidol_id"
          operations: [create, read, update, delete]
        }
      ]
    )
  priority_payment_auth_message: String
    @auth(
      rules: [
        {
          allow: groups
          groupsField: "buyer_paidol_id"
          operations: [create, read, update, delete]
        }
      ]
    )
  priority_response: String
    @auth(
      rules: [
        {
          allow: groups
          groupsField: "buyer_paidol_id"
          operations: [create, read, update, delete]
        }
      ]
    )
  status: PaymentFileQueueStatusEnum!
    @auth(
      rules: [
        {
          allow: groups
          groupsField: "buyer_paidol_id"
          operations: [create, read, update, delete]
        }
      ]
    )
}

Log output

# Put your logs below this line


Additional information

No response

jayKayEss avatar May 27 '22 20:05 jayKayEss