> ## 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
  }
}
```
