首页 > 解决方案 > accounts-js GraphQL 客户端身份验证突变不起作用

问题描述

在 Apollo GraphQL 游乐场中,我有以下突变:

mutation {
  authenticate(
    serviceName: "password"
    params: {
      user: { email: "john.doe@john.com" }
      password: "superSecurePassword"
    }
  ) {
    sessionId
    tokens {
      accessToken
      refreshToken
    }
    user {
      id
    }
  }
}

客户端我尝试以下操作:

export const LOGIN_USER = gql`
  mutation Authenticate($email: String!, $password: String!) {
    authenticate(email: $email, password: $password) {
      id
      token
    }
  }
`;

抛出异常:

 46 | // Constructs an instance of ApolloError given a GraphQLError
 47 | // or a network error. Note that one of these has to be a valid
 48 | // value or the constructed error will be meaningless.

我哪里错了?

标签: javascriptapollo-clientapollo-servergraphql-js

解决方案


尝试这个

导出 const LOGIN_USER = gql mutation Authenticate($email: String!, $password: String!) { authenticate(email: $email, password: $password) { sessionId tokens { accessToken refreshToken } user { id } } };


推荐阅读