docs icon indicating copy to clipboard operation
docs copied to clipboard

Confusion between Amplify and Appsync SDK uploading images / complex objects

Open BernhardSmuts opened this issue 4 years ago • 5 comments

Page: /lib/graphqlapi/advanced-workflows/q/platform/js

Feedback:

I am a low experience developer and it took me really long to figure out that this code snippet and the associated example rely on the Appsync SDK + Appollo and are not pure Amplify operations.

Maybe this can be communicated in the docs a bit more clearly with a comparison shown between the pure amplify method:

[(https://github.com/dabit3/react-amplify-appsync-files-s3)]

and the Appsync + Appollo method:

https://github.com/aws-samples/aws-amplify-graphql

I hope I am understanding it correctly.

BernhardSmuts avatar May 12 '20 13:05 BernhardSmuts

Hello @BernhardSmuts 👋 and apologies for how long it's taken us to reply to this. Our delayed response was likely due to the fact that Amplify libraries still don't have a great way to support complex objects. Did you ever find a workaround?

cwomack avatar Dec 14 '22 16:12 cwomack

Hi @cwomack, I can't for the life of me remember what the goal was with using this question, it's been nearly two years since I had this issue.

I think it was related to using images with AWS amplify and getting the image URL with a single call from the GraphQL DB. I mostly just store the image key as a string in DynamoDB now and then use that string with a Storage.get() call to get the full image URL, not sure if it's the best method, but it works, it's just pretty slow because it's two API calls just to get an image. Would love to know better ways to handle images using Amplify, not getting much out of the docs or on the discord channels so kinda feeling around in the dark for ways to do it. Would love to be pointed in the right direction.

BernhardSmuts avatar Dec 14 '22 17:12 BernhardSmuts

Hey @BernhardSmuts , I think the only thing that might've changed as far as AppSync + S3 is the Complex Objects feature.

Is this something that you might've already tried? I'm not sure from memory whether or not it was available at the time this issue was created.

Complex Objects in your Amplify graphql schema will adjust the resolvers so that files are uploaded to S3 for you. However, I'm not certain what the behavior is or response looks like when querying a record containing an S3 object. Might be worth looking into to see if it fits your use case.

https://docs.amplify.aws/lib/graphqlapi/advanced-workflows/q/platform/js/#complex-objects

chrisbonifacio avatar Dec 14 '22 18:12 chrisbonifacio

Hi @chrisbonifacio , thanks for the response. Yes this documentation was available at the time I had the issue and as far as I can see nothing has changed.

I have read through it again and what caught my out initially was that it seems to use the AWSAppSyncClient (Which I think comes from the AWS SDK) and not just the normal AWS Amplify GraphQL API type of calls. The GitHub code they use as an example seems like a very bloated example, importing other clients as well.

My initial query was more focused on how the docs were written because as someone learning Amplify this was very confusing, even after using Amplify for nearly 2 years now I still don't really understand it and just use workaround methods to upload images as mentioned above.

Again, I am a low-experience developer, so this problem might not be experienced by everyone.

BernhardSmuts avatar Dec 14 '22 18:12 BernhardSmuts

Hey @BernhardSmuts, Please refer to this reference for the sample implementation. We will add the official Amplify documentation soon.

AnilMaktala avatar Mar 22 '23 20:03 AnilMaktala