Skip to Content
全栈Serverless
book

全栈Serverless

by Nader Dabit
March 2022
Intermediate to advanced
205 pages
3h 9m
Chinese
China Electric Power Press Ltd.
Content preview from 全栈Serverless
AWS AppSync
应用
|
139
8.1.3
身份验证
通过
GraphQL Transform
库,我们还可以使用
@auth
指令为
API
定义不同的
授权规则。
使用
@auth
,我们可以定义多种规则,其中包括(但不限于)以下规则:
•
允许所有用户创建和读取,但是只有项目创建者可以更新和删除。
•
仅允许特定的用户能够创建,更新和删除。
•
使所有用户都能阅读,但不能执行任何其他操作。
•
上述规则的某种组合。
在该示例中,我们将要构建的应用程序会支持私有和公共访问,但是我们还
需要对这些规则进行更精细的控制。将要满足的要求如下所示:
•
属于
Amazon Cognito
用户组
Admin
并且经过身份验证的用户将拥有以下
权限:创建,读取,更新和删除。
•
未经身份验证的用户将拥有只读访问权限。
8.1.4
使用
GSI
实现自定义数据访问模式
DynamoDB
最强大的功能之一(在撰写本书时)是每个数据表支持额外的
20
个
GSI
。通过使用
GSI
或
GIS+
排序键的组合(也可以将其视为过滤器键),
你可以为数据创建极其灵活并强大的数据访问模式。
GraphQL Transform
库还
包含
@key
指令,可以轻松地为
@model
类型配置自定义索引结构。
我们将使用
@key
指令创建访问模式,该模式将通过
Performance
表上将舞台
ID
设置为
GSI
来查询给定舞台
ID
的相关演出节目。这样将使我们能够在单
个
GraphQL
查询中查询舞台及其相应的表演节目。
我们已对将会用到的技术进行了简要阐述,接下来将开始构建应用程序。
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

人工智能技术与大数据

人工智能技术与大数据

Posts & Telecom Press, Anand Deshpande, Manish Kumar
Python实用技能学习指南

Python实用技能学习指南

Posts & Telecom Press, Robert Smallshire, Austin Bingham
流架构

流架构

James Urquhart

Publisher Resources

ISBN: 9787519864453