有人知道如何处理变异过程中的这种错误吗?
发生在以下位置:
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 >);
};使用
"apollo-cache": "^1.1.9",
"apollo-cache-inmemory": "^1.2.1",
"apollo-client": "^2.3.1",
"apollo-link": "^1.2.2",
"apollo-link-error": "^1.0.9",
"apollo-link-http": "^1.5.4",
"apollo-link-state": "^0.4.1",
"graphql": "^0.13.2",
"graphql-tag": "^2.9.2",
"lodash": "^4.17.5",
"react": "16.3.1",
"react-apollo": "^2.1.4",
"react-native": "~0.55.2"基于Robin Wieruch教程https://www.robinwieruch.de/react-apollo-link-state-tutorial/#apollo-link-state-mutation

发布于 2018-06-05 16:20:38
问题是使用参数调用解析器。它们已经作为variables提供了,所以(有点混乱),解析器toggleSelectRepository应该在没有任何参数的情况下调用。
对此进行测试,我看到确实提供了variables中指定的参数。
<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>https://stackoverflow.com/questions/50677605
复制相似问题