使用apollo和AWS的GraphQL中的突变

时间:2018-07-12 06:22:29

标签: amazon-web-services apollo-client aws-appsync

const query = require('graphql-tag');
  const x = query(`
  mutation Hello {
  putPost(
    category: "College",
      institution: "Some College",
      address: "DisneyLand",
      country: "India",
      state: "Some State",
      city: "Some City"
  ){
    category
  }
}`);

  const client = new AWSAppSyncClient({
    url: url,
    region: region,
    auth: {
      type: type,
      apiKey:apiKey,
    }
  });
  console.log(x);

  client.hydrated().then(function (client) {
    return client.mutate({mutation : x})
  }).then(function logData(data) {
    console.log("This is the data returned " + data);
  }).catch(console.error);
}

我正在尝试使用AWS服务及其Apollo SDK更改数据库,我无法更改数据,并且发生错误“ TypeError:无法读取未定义的'queryManager'属性”,有人可以帮助我吗?

1 个答案:

答案 0 :(得分:1)

经过一番挖掘,我发现这是Aws-appsync模块版本的问题。我安装了“ 1.0.22”,一切正常。希望对您有所帮助。