【发布时间】:2022-01-05 09:46:08
【问题描述】:
我有这个搜索某个产品的 gql 查询,但是这个 ID 是硬编码的 如何用变量替换此 ID (product(id: "apple-imac-2021"))?
const CURRENT_PRODUCT = gql`
query {
product(id: "apple-imac-2021") {
name
inStock
gallery
description
brand
attributes {
name
type
items {
value
}
}
prices {
currency {
label
symbol
}
amount
}
}
}
`;
【问题讨论】:
-
嗨,有趣,也许这可能是有趣的stackoverflow.com/questions/41632152/…
-
我正在使用 useQuery() 钩子来执行这个查询,我不能提到 CURRENT_PRODUCT gql 中的变量吗?