我试图找出如何使用apollo-link-http与apollo-upload-client.
两者都创建一个终止链接,但我怎么能一起使用这两个?在我的index.js中我喜欢这个,但它不会工作因为两个链接都终止=>
const uploadLink = createUploadLink({ uri: process.env.REACT_APP_GRAPHQL_URL }); const httpLink = new HttpLink({ uri: process.env.REACT_APP_GRAPHQL_URL }); const client = new ApolloClient({ link: ApolloLink.from([ authLink, logoutLink, stateLink, uploadLink, httpLink ]), cache, });
有帮助吗?我对Apollo/Graphql没什么经验,但我想使用文件上传组件.
如果使用apollo-upload-client
高于6的版本,则不需要http链接.
你可以尝试这样:
const uploadLink = createUploadLink({ uri: process.env.REACT_APP_GRAPHQL_URL });
const client = new ApolloClient({
link: ApolloLink.from([ authLink, logoutLink, stateLink, uploadLink ]),
cache,
});