我花了一个小时左右的时间浏览了GraphIQL指南和自述文件,但没有看到任何关于如何将客户端定向到特定端点/端口的文档。我是runni
我在本地从项目的根目录运行graphiql。我有一个运行后端的graphql服务器,我只想将GraphIQL定向到它。
发布于 2020-07-05 09:40:11
docs概述了GraphiQL React组件上可用的所有属性。如果您有可用的GraphQLSchema实例,则可以将其作为schema参数直接传递。否则,您只需将您的fetcher指向适当的URL:
async function graphQLFetcher(graphQLParams) {
return fetch(YOUR_GRAPHQL_ENDPOINT_URL, {
method: 'post',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(graphQLParams),
})
.then(response => response.json())
.catch(() => response.text());
}
ReactDOM.render(<GraphiQL fetcher={graphQLFetcher} />, document.body);https://stackoverflow.com/questions/62735528
复制相似问题