我试图将文件上传到我的 apollo 服务器,但我无法上传任何文件,它也没有抛出任何错误,但我在解析器中只收到空对象,并且在我使用 GraphQL 客户端时可以找到它 strong> 喜欢 Altair
使用 Altair 客户端时服务器中的输出
{
filename: 'Copy of Massive Orange Summer Sale Animated-300x250px-MediumRectangle.png',
mimetype: 'image/png',
encoding: '7bit',
createReadStream: [Function: createReadStream]
}
使用@apollo/client 包时在服务器中的输出
{}
客户端代码
服务器代码
答案 0 :(得分:1)
默认情况下,Apollo 客户端不支持上传。如果您想启用它们,您需要使用 createUploadLink
中的 apollo-upload-client
,如here 所示。
import { createUploadLink } from 'apollo-upload-client';
const client = new ApolloClient({
cache: new InMemoryCache(),
link: createUploadLink(),
});