我正在尝试使用此npm package来生成Graphql文档。
这是我使用过的查询
function fetcher(query) {
const queryLog = gql`myquery`;
return fetch(window.location.origin + '/graphql', {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: queryLog,
}),
}).then(function(r) {
return r.json();
});
}
但是它抛出了错误
TypeError: Cannot read property 'GraphQLDocs' of undefined
有人可以帮我怎么使用吗?
答案 0 :(得分:0)
您需要在脚本顶部导入包
import { GraphQLDocs } from 'graphql-docs';
将渲染更改为
<GraphQLDocs fetcher={fetcher} />
文档未更新。源代码中包含一个示例 https://github.com/mhallin/graphql-docs/tree/master/example
不建议使用此软件包,因为它从2年前就没有更新。