【问题标题】:accounts-js GraphQL client side authenticate mutation not workingaccounts-js GraphQL 客户端身份验证突变不起作用
【发布时间】:2021-06-14 07:17:51
【问题描述】:

在 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.

我哪里错了?

【问题讨论】:

    标签: javascript apollo-client apollo-server graphql-js


    【解决方案1】:

    试试这个

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

    【讨论】:

    • 嘿,谢谢易卜拉欣,但它不起作用。让我特别困惑的是 serviceName: "password" 并且作为参数传入的电子邮件属性嵌套在用户对象中。如何将其翻译成客户端代码?
    猜你喜欢
    • 2020-12-26
    • 2017-04-08
    • 2014-09-15
    • 2021-08-21
    • 1970-01-01
    • 1970-01-01
    • 2018-04-13
    • 2016-07-09
    • 1970-01-01
    相关资源
    最近更新 更多