I'm using react-relay/compat 1.1.0
and I need to write a mutation with the ability to upload a file.
In Relay Classic you can use getFiles()
to support file uploads in mutations:
class AddImageMutation extends Relay.Mutation {
getMutation() {
return Relay.QL`mutation{ introduceImage }`;
}
getFiles() {
return {
file: this.props.file,
};
}
...
}
But haven't found any trace of functionality for uploading files in 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: ... ?
},
);
Is that supported yet in relay modern? and if so, what's the way of doing it? Thanks.