【问题标题】:How can I make a field public in AWS Amplify graphql schema?如何在 AWS Amplify graphql 架构中公开字段?
【发布时间】:2020-01-05 18:41:25
【问题描述】:

我正在为一组用户编写 AWS amplify graphql 架构。我希望用户名是公开的(因此任何人都可以通过用户名搜索和查找用户)并且用户的信息(描述等)是私有的(只有关注者可以看到)。

我知道如何使用@auth 来设置私人数据,但如何将用户名设为公开?

【问题讨论】:

    标签: amazon-cognito aws-amplify aws-amplify-cli


    【解决方案1】:

    看起来这个 PR 将实现这个 https://github.com/aws-amplify/amplify-cli/pull/1916

    【讨论】:

      【解决方案2】:

      您可以允许通过 ApiKey 访问公共架构,但使用 @aws_iam 装饰器限制字段

      type Post @aws_api_key {
          id: ID!
          author: String
          title: String
          content: String
          url: String
          ups: Int!
          downs: Int!
          version: Int!
          restrictedContent: String!
          @aws_iam
      }
      

      https://github.com/aws/aws-appsync-community/issues/1

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-04-05
        • 2021-10-04
        • 2019-12-14
        • 2019-05-30
        • 2020-12-10
        • 2020-08-19
        • 1970-01-01
        • 2021-09-29
        相关资源
        最近更新 更多