验证错误 GraphQL gql 查询字符串

编程入门 行业动态 更新时间:2024-10-05 01:23:15

验证错误 GraphQL gql 查询<a href=https://www.elefans.com/category/jswz/34/1771434.html style=字符串"/>

验证错误 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 查询字符串

本文发布于:2024-05-30 18:43:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1770803.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   错误   GraphQL   gql

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!