如果分支中存在设置,为什么已部署的应用程序不连接到GraphQL端点?

时间:2019-04-08 02:00:28

标签: deployment vuejs2 graphql aws-amplify

我有一个基本的VueJS应用程序,该应用程序通过GraphQL连接到AWS Amplify DynamoDB。一切连接,数据可在本地使用。该应用程序也可以成功部署在给定的分支机构上。

但是,即使GraphQL端点设置中包含aws-exports文件,部署的应用程序也不会连接到数据库。

// WARNING: DO NOT EDIT. This file is automatically generated by AWS Amplify. It will be overwritten.

const awsmobile =  {
    "aws_appsync_graphqlEndpoint": "https://xxxxxxx.appsync-api.us-east-2.amazonaws.com/graphql",
    "aws_appsync_region": "us-east-2",
    "aws_appsync_authenticationType": "API_KEY",
    "aws_appsync_apiKey": "xxxxxxxx",
};

export default awsmobile;

相反,通过此链接访问应用程序会引发此错误:

"No graphql endpoint provided."

我使用AWS Amplify控制台进行了部署。任何建议表示赞赏。

1 个答案:

答案 0 :(得分:0)

经过一番窥探,我找到了解决方法,这很简单。仅具有AppSync设置是不够的,我们必须使用GraphQL端点和api密钥实际配置Amplify,如下所示:

Amplify.configure(aws_exports);
Vue.use(AmplifyPlugin, AmplifyModules);
Vue.config.productionTip = false

Amplify.configure({
  API: {
    graphql_endpoint: 'https://xx.appsync-api.us-east-2.amazonaws.com/graphql',
    graphql_headers: async () => ({
      'x-api-key': 'xxxx',
    })
  }
});