【发布时间】:2022-10-05 20:21:17
【问题描述】:
根据https://apollo-angular.com/docs/data/network#file-upload,为了使用 Apollo Angular 上传文件,您必须将 context: {useMultipart: true} 添加到 graphQL 查询,并将 extractFiles 函数添加到 httpLink 创建。
但是,我不断收到此错误。似乎没有使用默认的isExtractableFile 函数,我不知道为什么会这样。
这是我的graphql.module.ts:
const uri = environment.graphQLUrl; // <-- add the URL of the GraphQL server here
export function createApollo(httpLink: HttpLink): ApolloClientOptions<any> {
return {
link: httpLink.create({uri, useMultipart: true, extractFiles}),
cache: new InMemoryCache(),
};
}
@NgModule({
exports: [ApolloModule],
providers: [
{
provide: APOLLO_OPTIONS,
useFactory: createApollo,
deps: [HttpLink],
},
],
})
export class GraphQLModule {}
-
您是否尝试过使用链接的 Angular 文档中的
extractFiles函数示例来查看两者之间是否存在任何差异?
标签: angular file-upload graphql apollo apollo-client