Azure / Azure/data-api-builder

Cosmos updates require id field on input object as well as mutation argument

Đang mở
#625 3 bình luận 0 reaction 2 người được giao Xem trên GitHub

@tarazou9 đang làm issue này rồi.

Từ ngày 2/8/2022.

bug cosmos graphql
Ngôn ngữ chính
C#
Star
1.5k
Fork
372
Merge trung bình
3 ngày 22 giờ
Pull request đã merge (30 ngày)
9

Mô tả

Given an ObjectType defined like so:

type Planet @model {
  id: ID
  name: String
  character: Character
  age: Int
  dimension: String
  stars: [Star]
}

The following update mutation is generated:

  updatePlanet(
     id: ID!
    _partitionKeyValue: String!
    item: UpdatePlanetInput!
  ): Planet

And it requires an UpdatePlanetInput defined here:

input UpdatePlanetInput {
  id: ID
  name: String
  character: UpdateCharacterInput
  age: Int
  dimension: String
  stars: [UpdateStarInput]
}

The id parameter is required to the updatePlanet mutation, but it also appears on the UpdatePlanetInput, but it's nullable, as the update is a partial update.

When run, this will result in an error that the update has failed because the id field wasn't provided on the object passed to container.ReplaceItem.

Manually providing the value for id on the item parameter will solve this (but can run into #296, depending on how you provide the value).

It probably makes sense that if the id is not provided on the item parameter, we inject it before calling the Cosmos SDK.

Also, should we be using UpsertItem not ReplaceItem to perform the partial update against a Cosmos document?

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.