Ale*_*zev 1 apollo graphql react-apollo
使用REST-API,我们可以进行获取查询,而不是对服务器进行查询。我使用“ Apollo-client”,但是我想创建查询而不将查询连接到组件。我可以做吗?可能我应该使用方法client.query(http://dev.apollodata.com/core/apollo-client-api.html#ApolloClient.query)和client.mutate或类似的方法?
const apolloClient = new ApolloClient({
networkInterface: createNetworkInterface({uri: 'http://localhost:3003/graphql'})
});;
const loginQueruy = gql `Your query code here`,
Run Code Online (Sandbox Code Playgroud)
然后在代码中
const apolloQuery = {
query: loginQuery,
};
apolloClient
.query(apolloQuery)
.then((res) => {
console.log("RES", res)
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
994 次 |
| 最近记录: |