React native “阿波罗突变”;在此环境中,分配的源必须是对象;

React native “阿波罗突变”;在此环境中,分配的源必须是对象;,react-native,graphql,apollo,react-apollo,mutation,React Native,Graphql,Apollo,React Apollo,Mutation,有人知道在突变过程中如何处理这种错误吗 发生在以下位置: const RepositoryItem = ({ repository, selectedRepositoryIds }: IProps) => { const isSelected = _.includes(selectedRepositoryIds, repository.id); return ( <View style={Theme.para}> <

有人知道在突变过程中如何处理这种错误吗

发生在以下位置:

const RepositoryItem = ({ repository, selectedRepositoryIds }: IProps) => {
    const isSelected = _.includes(selectedRepositoryIds, repository.id);
    return (
        <View style={Theme.para}>
            <View style={Theme.horizontalTopLeft}>
                <Mutation
                    // @ts-ignore - mappings incorrect for Mutations
                    mutation={SelectRepository}
                    variables={{ id: repository.id, isSelected }}>
                    {(toggleSelectRepository: ((id: string, isSelected: boolean) => void)) =>
                        (<Switch value={isSelected}
                            onValueChange={(val) => {
                                const {id} = repository;
                                toggleSelectRepository(id, val);
                                }} />)}
                </Mutation>

            </View>
        </View >);
};
基于Robin Wieruch教程


问题是使用参数调用冲突解决程序。这些已经作为
变量
提供,因此(有点混淆),应该在没有任何参数的情况下调用解析器
toggleSelectRepository

通过测试,我发现参数确实是按照
变量中的规定提供的

        <Mutation
            // @ts-ignore - mappings incorrect for Mutations
            mutation={SelectRepository}
            variables={{ id: repository.id, isSelected }}>
            {(toggleSelectRepository, { loading, error }: GenericResponse) => {
                if (error) {
                    return <FormValidationMessage>{error.message}</FormValidationMessage>;
                }
                if (loading) {
                    return <BusyIndicator isBusy message='One sec..' />;
                }

                return (<Switch
                    value={isSelected}
                    onValueChange={() => toggleSelectRepository()} />);
            }}
        </Mutation>

{(toggleSelectRepository,{loading,error}:GenericResponse)=>{
如果(错误){
返回{error.message};
}
如果(装载){
返回;
}
返回(toggleSelectRepository()}/>);
}}

您可以分享您的查询吗?或者更具体地说,是
toggleSelectRepository
ur突变函数的名称吗?谢谢@MohsenZareZardeyni-问题是我给解析器的参数。见答案
        <Mutation
            // @ts-ignore - mappings incorrect for Mutations
            mutation={SelectRepository}
            variables={{ id: repository.id, isSelected }}>
            {(toggleSelectRepository, { loading, error }: GenericResponse) => {
                if (error) {
                    return <FormValidationMessage>{error.message}</FormValidationMessage>;
                }
                if (loading) {
                    return <BusyIndicator isBusy message='One sec..' />;
                }

                return (<Switch
                    value={isSelected}
                    onValueChange={() => toggleSelectRepository()} />);
            }}
        </Mutation>