【问题标题】:Setting up a second Amplify project using the same GraphQL resources使用相同的 GraphQL 资源设置第二个 Amplify 项目
【发布时间】:2019-12-08 05:24:27
【问题描述】:

我们有一个现有的 AWS Amplify 项目,其中包含身份验证、api、存储、托管等。运行良好。我们现在需要使用相同的 DynamoDB 表、GraphQL 模式等创建一个单独的可公开访问的站点,而无需身份验证,并且具有不同的托管和存储资源。我们在 StackOverflow 上查看了几个类似的问题,但没有任何答案。我们最好的猜测是复制 Amplify 配置文件并删除与 api 无关的配置文件和部分 - 但如果可行的话,这似乎是一种 hack。

有什么官方方法可以尝试吗?

【问题讨论】:

    标签: amazon-web-services aws-amplify amplifyjs


    【解决方案1】:

    不,你是on the right track

    手动传入要覆盖的资源,并为其他所有资源生成新资源。

    import { mergeDeepLeft } from 'ramda';
    import Amplify from '@aws-amplify/core';
    import config from './aws-exports';
    
    const myAppConfig = {
        // ...
        'aws_appsync_graphqlEndpoint': 'https://xxxxxx.appsync-api.us-east-1.amazonaws.com/graphql',
        'aws_appsync_region': 'us-east-1',
        'aws_appsync_authenticationType': 'API_KEY',
        'aws_appsync_apiKey': 'da2-xxxxxxxxxxxxxxxxxxxxxxxxxx',
        // ...
    }
    
    Amplify.configure(mergeDeepLeft(myAppConfig, config));
    

    【讨论】:

    • 谢谢。对于私有站点,我们通过 Cognito 用户池保护我们的 API,因此您必须通过身份验证才能访问 API。我们还在 AppSync 上添加了 API 密钥访问作为替代身份验证机制。然后我们可以使用公共应用程序中的手动配置通过 API 密钥访问吗?第二个问题 - 2019 年 5 月,AppSync 通过“@aws_api_key”之类的指令添加了对通过架构强制执行的多种身份验证机制的支持。 Amplify 会很快支持这个吗?
    猜你喜欢
    • 1970-01-01
    • 2012-11-02
    • 1970-01-01
    • 2023-01-01
    • 2020-03-27
    • 2021-11-17
    • 2015-01-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多