本文介绍了手动发送请求到GraphQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用Apollo将请求手动发送到graphql服务器,
I want to send manually requests to a graphql server using Apollo,
实际上,我将我的应用程序包装在ApolloProvider中,并且每次渲染组件时都会发送请求.这是我组件的代码:
Actually Im wrapping my App in an ApolloProvider and the requests are send each time I render my component. Here is the code of my component :
export default graphql(gql`
query Hello{
hello
}
`)(myComponent);
我如何手动发送graphql请求,而无需通过组件渲染(例如,通过单击按钮进行处理).
How may I send the graphql requests manually without passing by the component rendering (handled by buttons clicks for example).
推荐答案
您可以使用 apollo-fetch 运行与您的Apollo商店集成的独立graphql查询.
You can use apollo-fetch to run standalone graphql queries that integrate with your Apollo store.
这篇关于手动发送请求到GraphQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!