> ## Documentation Index
> Fetch the complete documentation index at: https://docs.waffo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# ストアと商品

> ストア、商品、商品バージョンの GraphQL クエリ例

## ストア

### すべてのストアを一覧表示

```graphql theme={"system"}
query {
  stores {
    id
    name
    status
    slug
    supportEmail
    website
    prodEnabled
    createdAt
    updatedAt
  }
}
```

### ネストされた商品を含む単一ストア

```graphql theme={"system"}
query($storeId: ID!) {
  store(id: $storeId) {
    id
    name
    status
    onetimeProducts {
      id
      name
      prices
      status
    }
    subscriptionProducts {
      id
      name
      billingPeriod
      prices
      status
    }
  }
}
```

**変数：**

```json theme={"system"}
{ "storeId": "STO_3bVzrkD0FJjFdZNLk8Ualx" }
```

***

## 単発商品

### フィルタリングで商品を一覧表示

```graphql theme={"system"}
query($storeId: String!) {
  onetimeProducts(
    filter: {
      storeId: { eq: $storeId }
      status: { eq: "active" }
    }
    limit: 20
    offset: 0
  ) {
    id
    name
    description
    prices
    status
    version
    media
    successUrl
    metadata
    createdAt
    updatedAt
  }
  onetimeProductsCount(
    filter: { storeId: { eq: $storeId } }
  )
}
```

**変数：**

```json theme={"system"}
{ "storeId": "STO_3bVzrkD0FJjFdZNLk8Ualx" }
```

### SDK の例

```typescript theme={"system"}
const result = await client.graphql.query<{
  onetimeProducts: Array<{
    id: string;
    name: string;
    prices: Record<string, { amount: string; taxCategory: string }>;
    status: string;
  }>;
  onetimeProductsCount: number;
}>({
  query: `query($storeId: String!) {
    onetimeProducts(filter: { storeId: { eq: $storeId }, status: { eq: "active" } }, limit: 20) {
      id name prices status
    }
    onetimeProductsCount(filter: { storeId: { eq: $storeId } })
  }`,
  variables: { storeId: "STO_3bVzrkD0FJjFdZNLk8Ualx" },
});
```

***

## サブスクリプション商品

### サブスクリプション商品の一覧表示

```graphql theme={"system"}
query($storeId: String!) {
  subscriptionProducts(filter: { storeId: { eq: $storeId } }) {
    id
    name
    description
    billingPeriod
    prices
    status
    version
    media
    metadata
    createdAt
    updatedAt
  }
  subscriptionProductsCount(filter: { storeId: { eq: $storeId } })
}
```

***

## 商品バージョン

### バージョン履歴のクエリ

商品の更新ごとにイミュータブルバージョンが作成されます。バージョン履歴をクエリして過去のすべての設定を確認できます：

```graphql theme={"system"}
query($productId: String!) {
  onetimeProductVersions(filter: { productId: { eq: $productId } }) {
    id
    versionNumber
    name
    description
    prices
    media
    createdAt
  }
}
```

### サブスクリプション商品バージョン

```graphql theme={"system"}
query($productId: String!) {
  subscriptionProductVersions(filter: { productId: { eq: $productId } }) {
    id
    versionNumber
    name
    billingPeriod
    prices
    metadata
    createdAt
  }
}
```

**変数：**

```json theme={"system"}
{ "productId": "PROD_4cWAslE1GKkGeaOMl9Vbmy" }
```

***

## マーチャント

### マーチャントの一覧表示

```graphql theme={"system"}
query {
  merchants {
    id
    email
    status
    createdAt
  }
  merchantsCount
}
```

### 単一マーチャント

```graphql theme={"system"}
query($id: ID!) {
  merchant(id: $id) {
    id
    email
    status
    createdAt
    updatedAt
  }
}
```
