我正在尝试在Relay-Modern应用程序中从'gralphql-tools'设置GraphQL mockServer但是收到此错误:
parser.js:152 Uncaught
GraphQLError {message: "Syntax Error GraphQL (1:1) Unexpected Name "data"↵…GVUeXBlIHsKICBVUAogIERPV04KICBDQU5DRUwKfQo=↵ ^↵", locations: Array(1), path: undefined, stack: "GraphQLError↵ at syntaxError (http://localhost:…tp://localhost:3000/static/js/bundle.js:33240:27)", nodes: undefined…}
locations
:
Array(1)
message
:
"Syntax Error GraphQL (1:1) Unexpected Name "data"↵↵1:
我正在尝试使用relay-modern-hello-world http://graphql.org/blog/mocking-with-graphql/实现repo中概述的策略。
我基本上尝试替换fetchQuery()以将post请求替换为示例中包含的API:
function fetchQuery() {
mockServer(schema, {
Int: () => 6,
Float: () => 22.1,
String: () => 'Hello',
});
const appQuery = `
query AppFeedQuery {
feed (type: NEW, limit: 5) {
...Feed
}
}
`;
return mockServer.query(appQuery);
}
// Create a network layer from the fetch function
const network = Network.create(fetchQuery);
const source = new RecordSource();
const store = new Store(source);
我的尝试可以在https://github.com/sdee/relay-modern-hello-world
找到我很欣赏任何想法。我是Relay和GraphQL的新手。谢谢!