字符串"/>
验证错误 GraphQL gql 查询字符串
我正在尝试通过 executeOperation 执行此突变,但我想稍后重用我在突变中作为 GiftcardRestriccionInput 发送的信息。
const result = await apolloServer.executeOperation({
query: gql`mutation {
addGiftcardRestriccion(GiftcardRestriccionInput:
id_giftcard: 22,
id_empresa: 2,
restricciones: [
{
nombre: "sucursal",
label: "debe indicar la sucursal donde retirar la tarjeta",
descripcion: "alguna descripcion extra",
prop: "seleccion_simple"
}
]
) {
status,
message
data {
id_giftcard
id_empresa
restricciones {
descripcion
nombre
label
prop
}
}
}
}`
});
所以我想做的是将数据保存在一个 const 变量中,然后用字符串插值 (${}) 传递它
我收到这个错误
[[ValidationError: Expected value of type "GiftcardRestriccionInput", found [object, Object].]]
const data = {
id_giftcard: 22,
id_empresa: 2,
restricciones: [
{
nombre: "sucursal",
label: "debe indicar la sucursal donde retirar la tarjeta",
descripcion: "alguna descripcion extra",
prop: "seleccion_simple"
}
]
}
const result = await apolloServer.executeOperation({
query: gql`mutation {
addGiftcardRestriccion(GiftcardRestriccionInput:
${data}
) {
status,
message
data {
id_giftcard
id_empresa
restricciones {
descripcion
nombre
label
prop
}
}
}
}`
});
回答如下:
更多推荐
验证错误 GraphQL gql 查询字符串
发布评论