2017-07-24 40 views
2

我使用的是react-relay/compat 1.1.0,我需要编写一个能够上传文件的变种。 继电器经典,你可以使用getFiles()支持文件上传突变:如何使用Relay Modern突变进行文件上传?

class AddImageMutation extends Relay.Mutation { 
    getMutation() { 
    return Relay.QL`mutation{ introduceImage }`; 
    } 

    getFiles() { 
    return { 
     file: this.props.file, 
    }; 
    } 
    ... 
} 

,但没有发现任何功能跟踪上传文件Relay Modern文档:

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: ... ? 
    }, 
); 

的是,在被支持接力现代?如果是这样,那么做什么方式?谢谢。

回答

1

发现这个问题,因为我自己也有同样的问题。

不确定完整答案,但我开始阅读中继资源,并基于packages/relay-runtime/mutations/commitRelayModernMutation.js,看起来您可以将uploadables传递给您的变体。

相关问题