Azure / Azure/data-api-builder

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

オープン
#625 コメント 3 件 リアクション 0 件 担当者 2 名 @tarazou9 が担当を希望しています GitHub で見る
bug cosmos graphql
主要言語
C#
スター
1.5k
フォーク
370
平均マージ
3日 22時間
マージ済み PR(30日)
9

説明

Given an ObjectType defined like so:

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

The following update mutation is generated:

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

And it requires an `UpdatePlanetInput` defined here:

```graphql
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?

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。