graphQL 查询:出现错误 "Expected value of type ..., found ..."

graphQL Query: getting error "Expected value of type ..., found ..."

假设我有以下对象类型:

    type Price {
        currency: Currency!,
        amount: Float!
    }

    type Attribute {
        displayValue: String,
        value: String,
        id: String!
    }

    type AttributeSet {
        id: String!,
        name: String,
        type: String,
        items: [Attribute]
    }

    type Product {
        id: String!,
        name: String!,
        inStock: Boolean,
        gallery: [String],
        description: String!,
        category: String!,
        attributes: [AttributeSet]
        prices: [Price!]!,
        brand: String!
    }

    type Category {
        name: String,
        products: [Product]!
    }

    type Currency {
        label: String!,
        symbol: String!
    }

    input CategoryInput {
        title: String!
    }

    type Query {
        categories: [Category],
        category(input: CategoryInput): Category,
        product(id: String!): Product,
        currencies: [Currency]
    }

这些是 Category 的类型:

export enum Category {
    all = 'all',
    clothes = 'clothes',
    tech = 'tech'
};

在 graphQL Playground 中,我试图进行查询以显示类别为 all 的元素的所有名称和 products/id。这是我的尝试:

{
  category(input: "all") {
    name
    products {
      id
    }
  }
}

但我收到以下错误消息:

"message": "Expected value of type \"CategoryInput\", found \"all\".",

由于 all 是一个有效类型,我需要帮助来理解问题出在哪里。提前谢谢你。

刚刚发现我的错误

CategoryInput 是类型

input CategoryInput {
        title: String!
    }

所以正确的查询应该是:

{
  category(input: { title: "all" }) {
    name
    products {
      id
    }
  }
}