在开发shopify应用程序时,我遇到了graphQL的问题。逻辑很简单。我需要使用lineItems从shopify商店获得graphQL。这是gql的代码。
const GET_ORDER_DETAIL = gql`
query getOrderDetail($orderId: String) {
order(id: $orderId) {
name
physicalLocation {
id
}
lineItems (first:100){
edges {
node {
id
}
}
}
}
}
`;这是我的反应码。
{
this.state.refund_list.map((list, index) => {
const orderId = `gid://shopify/Order/${list.order_id}`; // I got correct orderId.
return (
<Query key={index} query={GET_ORDER_DETAIL} variables={{ id: orderId }}>
{({ data, loading, error }) => {
if (loading) return <div>loading...</div>;
if (error) return <div>{error}</div>;
console.log(data);
return <div>test</div>;
}}
</Query>
);
})
}这是错误的句子。
Uncaught Error: Objects are not valid as a React child (found: Error: GraphQL error: Type mismatch on variable $orderId and argument id (String! / ID!)). If you meant to render a collection of children, use an array instead.发布于 2020-05-12 03:16:52
我找到了$orderId的正确类型。我把String改成了ID!
这是我的固定密码。
const GET_ORDER_DETAIL = gql`
query getOrderDetail($orderId: ID!) {
...
}
`;...
<Query key={index} query={GET_ORDER_DETAIL} variables={{ orderId }}>
...https://stackoverflow.com/questions/61721416
复制相似问题