使用GraphQl突变
我应该通过node.js请求模块使用graphQl“查询”和“变异”。 我使用“查询”作为:使用GraphQl突变,graphql,Graphql,我应该通过node.js请求模块使用graphQl“查询”和“变异”。 我使用“查询”作为: 请求(“http://test.com/graphql/?query=query{allData{Id,name,price}}”, 功能(错误、响应、正文){ console.log(body);}) 它正确地为我返回所有数据 我使用与“突变”相同的代码在数据库中创建新数据: 请求(“http://test.com/graphql/?query=mutation{createData(名称:'name
请求(“http://test.com/graphql/?query=query{allData{Id,name,price}}”,
功能(错误、响应、正文){
console.log(body);})代码>
它正确地为我返回所有数据
我使用与“突变”相同的代码在数据库中创建新数据:
请求(“http://test.com/graphql/?query=mutation{createData(名称:'name-1',价格:1000)}”,函数(错误,响应,正文){
控制台日志(正文);
});代码>
但将新数据放入数据库并不能正常工作
你能帮我一下吗?试试这个
mutation{createData(name:'name-1',price:1000){name price}}