Node.js 无法在graphql中传递对象
有人能告诉我如何从react js端传递graphql中的对象数组吗?我尝试在react中传递对象,但得到了不同类型的错误Node.js 无法在graphql中传递对象,node.js,reactjs,facebook-graph-api,graph,graphql-js,Node.js,Reactjs,Facebook Graph Api,Graph,Graphql Js,有人能告诉我如何从react js端传递graphql中的对象数组吗?我尝试在react中传递对象,但得到了不同类型的错误 [input type][1] [from api side][2] [declaring the object][3] [passing object in mutation][4] [error i'm facing][5] [1]: https://i.stack.imgur.com/ufVtA.png [2]: https://i.stack.imgur.com
[input type][1]
[from api side][2]
[declaring the object][3]
[passing object in mutation][4]
[error i'm facing][5]
[1]: https://i.stack.imgur.com/ufVtA.png
[2]: https://i.stack.imgur.com/kQt5m.png
[3]: https://i.stack.imgur.com/hnxLM.png
[4]: https://i.stack.imgur.com/5JCHf.png
[5]: https://i.stack.imgur.com/BonPE.png
我从您的问题中了解到的是,您希望将对象数组作为参数传递给变异。这很容易做到 首先在模式中定义一个输入,如下所示。它的值名为string。你可以添加任何你想要的。此结构将用于将值作为参数传递
input Product {
name: String
}
上述创建的输入将作为数组传递,如下所示
type RootMutation{
createProduct(product: [Product]): String
}
您将在解析器中获得数据
createProduct: (args)=>{
// You will get the value in this 'args'
// Do Whatever you want
}
输入如下所示
createProduct(product:[{name:"has"}])
请提供代码和错误我请找到我添加的图片请阅读。我们希望您在这里给出正确的问题描述;仅仅举着图像并不被认为是一个问题。