当客户被宣布为突变时,Apollo会中断

时间:2017-09-02 22:00:53

标签: graphql graphql-js react-apollo apollo-client

我正在使用最近添加多个客户端的功能,到目前为止它运行良好,但只有在这种情况下,当我在我的突变选项中明确说明客户端时,以下代码会中断。我已经跟随其他组件的这个确切模式,并没有任何问题。

(<$>)

反应组件如下所示:

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);

实际结果: 我收到了这个错误:

  options: () => ({
    client: apolloClientAccounts,
  }),

之后,我可以提交表格。

apollo-client@1.9.1 react-apollo@1.4.15

0 个答案:

没有答案