【问题标题】:GraphQl generate Syntax Error: Expected $, found {]GraphQl 生成语法错误:预期 $,找到 {]
【发布时间】:2020-06-07 20:33:00
【问题描述】:
    laugh  =async()=>  {
    let mutation = gql`
    mutation SignUp({$Email: String!
      $Password: String!
    }){
       SignUp(data: {
        Email: "tael32@gmil.com"
        Password: "12345678"
      }) {
        User {
          _id
          Name
          Rating
          Photo
          Badge
          Email
        }
        Token
      }}
    `;
    try {
      let data = await client.mutate({mutation});
      console.log('TCL: login -> data', data);
    } catch (error) {
      console.log('Majid', error);
    }
  }

当我调用这个函数时,它会在代码中产生错误,而它在帖子中正确运行

mutation {
  SignUp(data: {
    Email: "chetanvirani@gmail.com"
    Password: "12345678"
    Name: "Chetan"
  }) {
    User {
      _id
      Name
      Rating
      Photo
      Password
      Badge
      Email
    }
    Token
  }
}

这里是在邮递员中运行但不在代码中运行的代码,我不知道我的代码中的错误是什么

【问题讨论】:

    标签: react-native graphql apollo-client


    【解决方案1】:

    花括号指定一个选择集。没有理由将变量定义用大括号括起来:

    mutation SignUp($Email: String!, $Password: String!) {
      ...
    }
    

    【讨论】:

      猜你喜欢
      • 2021-09-14
      • 2018-06-28
      • 2020-10-03
      • 2022-11-15
      • 2021-07-28
      • 2021-02-18
      • 2019-01-23
      • 2019-10-09
      • 2023-03-31
      相关资源
      最近更新 更多