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

商品在庫の更新のドキュメントを追加 #76

Merged
merged 1 commit into from
Aug 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 111 additions & 1 deletion docs/_pages/mutation/product_stock.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,114 @@ layout: home
author_profile: true
permalink: /mutation/product_stock
---
商品在庫の更新

## 商品在庫の更新

updateProductStock で商品在庫の更新ができます。
`stock_unlimited: false` の場合は `stock` が必須、`stock_unlimited: true` の場合は `stock` を指定できません。

### スキーマ

```graphql
type Mutation {
updateProductStock(
"""商品コード"""
code: String!

"""在庫数(在庫無制限の場合、0以上の数値を指定)"""
stock: Int

"""在庫無制限(無制限は true 、制限は false を指定)"""
stock_unlimited: Boolean!
): ProductClass
}
```

### 実行例

#### リクエスト(在庫有限)

```graphql
mutation {
updateProductStock (
code: "sand-01",
stock: 10,
stock_unlimited: false
) {
code
stock
stock_unlimited
}
}
```

#### レスポンス(在庫有限)

```json
{
"data": {
"updateProductStock": {
"code": "sand-01",
"stock": 10,
"stock_unlimited": false,
}
}
}
```

#### リクエスト(在庫無限)

```graphql
mutation {
updateProductStock (
code: "sand-01",
stock_unlimited: true
) {
code
stock
stock_unlimited
}
}
```

#### レスポンス(在庫無限)

```json
{
"data": {
"updateProductStock": {
"code": "sand-01",
"stock": null,
"stock_unlimited": true,
}
}
}
```

#### Variables を利用したリクエスト例

```graphql
mutation UpdateProductStock(
$code: String!,
$stock: Int,
$unlimited: Boolean!
){
updateProductStock (
code: $code,
stock: $stock,
stock_unlimited: $unlimited
) {
code
stock
stock_unlimited
}
}
```

```json
{
"code": "sand-01",
"stock": 10,
"unlimited": false
}
```