我正在使用最近添加多个客户端的功能,到目前为止它运行良好,但只有在这种情况下,当我在我的变异选项中明确说明客户端时,以下代码中断 . 我已经跟随其他组件的这个确切模式,并没有任何问题 .
import { gql } from 'react-apollo';
const networkInterfaceAccounts = createNetworkInterface({
uri: ACCOUNTS_CLIENT_URL,
});
networkInterfaceAccounts.use([authMiddleware]);
const apolloClientAccounts = new ApolloClient({
networkInterface: networkInterfaceAccounts,
reduxRootSelector: state => state.apolloAccounts,
});
export const signupRequestMutation = gql`
mutation signupRequest($username: String!, $fname: String!, $lname: String!) {
signupRequest(username: $username, firstName: $fname, lastName: $lname) {
_id
}
}
`;
export const signupRequestOptions = {
options: () => ({
client: apolloClientAccounts,
}),
props: ({ mutate }) => ({
signupRequest: ({ username, fname, lname }) => {
return mutate({
variables: {
username,
fname,
lname,
},
});
},
}),
};
反应组件看起来像这样:
export default compose(
graphql(signupRequestMutation, signupRequestOptions),
withRouter,
reduxForm({
form: 'signup',
validate,
}),
)(SignupForm);
Intended outcome: 与其他组件一样,无论我是否将客户端作为选项传递,我都希望该突变能够正常工作 .
options: () => ({
client: apolloClientAccounts,
}),
Actual outcome: 我收到此错误:
Uncaught Error: The operation 'signupRequest' wrapping 'withRouter(ReduxForm)' is expecting a variable: 'username' but it was not found in the props passed to 'Apollo(withRouter(ReduxForm))'
之后,我可以提交表格 .
版
apollo-client@1.9.1 react-apollo@1.4.15