-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support resolving AppSync data sources #3061
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,14 +13,15 @@ def __init__(self) -> None: | |
# { "LogicalId": {"Property": "Value"} } | ||
self._refs: Dict[str, Dict[str, Any]] = {} | ||
|
||
def add(self, logical_id, property_name, value): # type: ignore[no-untyped-def] | ||
def add(self, logical_id: str, property_name: str, value: str) -> None: | ||
""" | ||
Add the information that resource with given `logical_id` supports the given `property`, and that a reference | ||
to `logical_id.property` resolves to given `value. | ||
|
||
Example: | ||
|
||
"MyApi.Deployment" -> "MyApiDeployment1234567890" | ||
"SuperCoolAPI.DataSources:MyDataSource" -> "SuperCoolAPIMyDataSource" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here it's What happens when we add something else than |
||
|
||
:param logical_id: Logical ID of the resource (Ex: MyLambdaFunction) | ||
:param property_name: Property on the resource that can be referenced (Ex: Alias) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
Transform: AWS::Serverless-2016-10-31 | ||
Resources: | ||
SuperCoolAPI: | ||
Type: AWS::Serverless::GraphQLApi | ||
Properties: | ||
Name: SomeApi | ||
SchemaInline: | | ||
type Todo { | ||
id: ID! | ||
name: String | ||
description: String | ||
priority: Int | ||
} | ||
type Mutation { | ||
addTodo(id: ID!, name: String, description: String, priority: Int): Todo | ||
} | ||
type Query { | ||
getNote(id: ID!): Todo | ||
} | ||
schema { | ||
query: Query | ||
mutation: Mutation | ||
} | ||
XrayEnabled: true | ||
Auth: | ||
Type: AWS_IAM | ||
Tags: | ||
key1: value1 | ||
key2: value2 | ||
DynamoDBDataSources: | ||
MyDataSource: | ||
TableName: some-table | ||
TableArn: big-arn | ||
AnotherDataSource: | ||
TableName: cool-table | ||
TableArn: table-arn | ||
|
||
GetTodoResolver: | ||
Description: Don't do anything, just reference | ||
Type: AWS::AppSync::Resolver | ||
Properties: | ||
ApiId: !GetAtt SuperCoolAPI.ApiId | ||
DataSourceName: !GetAtt SuperCoolAPI.DataSources:AnotherDataSource.Name | ||
TypeName: Query | ||
FieldName: getNote | ||
RequestMappingTemplate: | | ||
{ | ||
"version": "2017-02-28", | ||
"operation": "GetItem", | ||
"key": { | ||
"NoteId": $util.dynamodb.toDynamoDBJson($context.arguments.id) | ||
} | ||
} | ||
ResponseMappingTemplate: $util.toJson($context.result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How necessary is this?
The
.
notation is useful for things that cannot be easily determined, such as the example above where the deployment includes a hash. For everything else, we document the generated logical IDs, so I'm not sure whether it's worth adding a new concept to refer to resources.