【发布时间】:2017-12-30 12:22:28
【问题描述】:
我正在使用react-relay/compat 1.1.0,我需要编写一个能够上传文件的突变。
在 Relay Classic 中,您可以使用 getFiles() 支持突变中的文件上传:
class AddImageMutation extends Relay.Mutation {
getMutation() {
return Relay.QL`mutation{ introduceImage }`;
}
getFiles() {
return {
file: this.props.file,
};
}
...
}
但在Relay Modern docs 中没有发现任何上传文件功能的痕迹:
const {commitMutation} = require('react-relay');
commitMutation(
environment: Environment,
config: {
mutation: GraphQLTaggedNode,
variables: Variables,
onCompleted?: ?(response: ?Object) => void,
onError?: ?(error: Error) => void,
optimisticResponse?: ?() => Object,
optimisticUpdater?: ?(store: RecordSourceSelectorProxy) => void,
updater?: ?(store: RecordSourceSelectorProxy) => void,
configs?: Array<RelayMutationConfig>,
// files: ... ?
},
);
在现代继电器中是否支持?如果是这样,这样做的方法是什么?谢谢。
【问题讨论】:
标签: graphql relay relaymodern