Is the S3Object GraphQL type that is available in AppSync (see Complex objects section in https://docs.aws.amazon.com/appsync/latest/devguide/building-a-client-app-ios.html) tied to dynamoDB, or could it be used with a Lambda datasource (say one connecting to a mongoDB)?
From the AWS docs linked above...
type Post {
id: ID!
author: String!
title: String
content: String
url: String
ups: Int
downs: Int
file: S3Object
version: Int!
}
type S3Object {
bucket: String!
key: String!
region: String!
}
input S3ObjectInput {
bucket: String!
key: String!
region: String!
localUri: String
mimeType: String
}
I haven't tried this, but you should be able to do what you're looking to accomplish and use a Lambda data source that reads/writes to something else like Mongo or even RDS. AppSync needs the GraphQL types of S3Object and S3ObjectInput along with the fields like bucket and so forth listed above for the client SDKs and codegen to properly build out objects, however the S3Link functionality is done in the resolver itself both for reading and writing. You could move this to your logic layer in a Lambda.
If you look at https://docs.aws.amazon.com/appsync/latest/devguide/resolver-context-reference.html#dynamodb-helpers-in-util-dynamodb you will see the mapping function signatures and output:
$util.dynamodb.toS3Object(String key, String bucket, String region) : Map
$util.dynamodb.toS3ObjectJson(String key, String bucket, String region) : String
$util.dynamodb.toS3Object(String key, String bucket, String region, String version) : Map
$util.dynamodb.toS3ObjectJson(String key, String bucket, String region, String version) : String
$util.dynamodb.fromS3ObjectJson(String) : Map
So if you want to move this logic to write/read into a Lambda that's completely possible. If you standup this sample you'll be able to reverse engineer it: https://github.com/aws-samples/aws-amplify-graphql
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With