繁体   English   中英

如何在Apollo-Client中进行查询?

[英]How to make query in Apollo-Client?

使用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`,

然后在代码中

const apolloQuery = {
        query: loginQuery,
    };
apolloClient
        .query(apolloQuery)
        .then((res) => {
            console.log("RES", res)
        })

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM