我是图形学的新手。我使用特快图形为petSore模式在REST上生成graphql查询。我能够使用graphql 查询获得get API的结果,但我无法使用突变获得POST/PUT API的响应。)为了制造宠物,我用变异作为,
mutation {
addPet(body: {id: "111", name: "doggie", photoUrls:["http://localhost:3000/pics/doggie"]}) {
name,
id
}
}在localhost:3000/graphql上运行此查询时,我在后端(nodejs错误)获得了错误,
uncaughtException: First argument must be a string or Buffer...如果有人能帮我理解我在这里做错了什么那就太好了.
Node.js代码:
'use strict';
var graphqlHTTP = require('express-graphql');
var graphQLSchema = require('swagger-to-graphql');
var pathToSwaggerSchema = require('./schema.json');
module.exports = function(server) {
var router = server.loopback.Router();
router.get('/', server.loopback.status());
graphQLSchema(pathToSwaggerSchema).then(schema => {
server.use('/graphql', graphqlHTTP((req) => {
return {
schema: schema,
context: {
GQLProxyBaseUrl: 'http://localhost:3000/api/v2/',
},
graphiql: true,
};
}));
}).catch(e => {
throw e;
});
server.use(router);
};我要遵循的程序是:
发布于 2019-04-25 11:15:20
突变声明不会添加到代码中。请加上突变
提供链接,以了解如何进行突变在这里输入链接描述。
https://stackoverflow.com/questions/50617256
复制相似问题