aws-amplify / aws-amplify/amplify-data
GraphQL AppSync S3 Upload with Complex Objects
- Dominant language
- TypeScript
- Stars
- 18
- Forks
- 23
- Avg merge
- 26m
- Merged PRs (30d)
- 1
Description
** Which Category is your question related to? **
GraphQL AppSync, and S3 Uploads with Complex Objects.
** What AWS Services are you utilizing? **
GraphQL AppSync, and S3 Uploads with Complex Objects.
** Provide additional details e.g. code snippets **
I have set up a simple Blog, but each article will require a single Feature Image, so I set up my schema as follows...
```
enum Visibility {
public
private
}
type Post @model {
id: ID!
title: String!
content: String!
feature: S3Object
gallery: S3Object
comments: [Comment] @connection(name: "PostComments")
author: [Author] @connection(name: "PostAuthor")
}
type S3Object {
bucket: String!
key: String!
region: String!
localUri: String
mimeType: String
}
type Author @model {
id: ID!
username: String!
email: String!
post: Post @connection(name: "PostAuthor")
}
type Comment @model {
id: ID!
content: String
post: Post @connection(name: "PostComments")
}
input S3ObjectInput {
id: ID
name: String!
description: String
file: S3ObjectInput
}
```
I have read the articles about complex objects, but the mutation looks like it needs some extra structure that looks to be missing in the documentation.
```
if (this.props.currentMethod === 'add') {
await API.graphql(graphqlOperation(createPost, { input: this.state }))
.then(result => {
console.log(result);
this.props.onChangeMethod('listing');
})
.catch(err => console.log(err));
}
```
Thats my existing createPost mutation, without the S3 Upload added... this.state doesn't have the feature object yet... I need to add 'feature' to my state.
If I add feature as
```
feature = {
bucket,
key,
region,
localUri: selectedFile,
mimeType,
};
```
Where do I upload the file? Do I add feature to the mutation state, to send it up to AWS... Do I do the S3 Upload separately with something else, and just store the key and such locally?
Contributor guide
Research direction
Start by comparing the documented complex-object flow with the GraphQL schema and createPost mutation shown here. Clarify the relationship between the S3 upload and Post creation, including which values belong in feature. Done means the documentation provides a complete upload-and-mutation sequence for this schema.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, graphql, typescript
- Domain
- api, cloud, documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100