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

Why doesn't a deployed app connect to the GraphQL endpoint when the the settings exist in the branch?

我有一个基本的 VueJS 应用程序,它使用 GraphQL 连接到 AWS Amplify DynamoDB。万物互联,数据可在本地使用。该应用程序也可以在给定的分支上成功部署。

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

// 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;

而是在此 link 访问应用程序会引发此错误:

"No graphql endpoint provided."

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

经过一番探索后,我找到了解决方法,而且非常简单。仅有 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',
    })
  }
});