Skip to content
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

SDK doesn't upload Complex objects to S3 if the input object of a mutation has fields which are of type "S3ObjectInput" #11

Closed
b1zantine opened this issue May 21, 2018 · 11 comments
Assignees

Comments

@b1zantine
Copy link

The SDK uploads Complex objects to S3 only if the query document has the text "S3ObjectInput" [1].

However, the text "S3ObjectInput" will be only present in the query document only if the input object of the mutation is of type "S3ObjectInput".

mutation ($obj: S3ObjectInput!){
  putUser(obj: $obj){
      bucket
      region
      key
  }
}

The query document will not have the word "S3ObjectInput" in cases like the following. Here, UserInput has another object called pic which is of type 'S3ObjectInput`.

mutation ($user: UserInput!){
  putUser(user: $user){
    user
    email
    pic {
      bucket
      region
      key
    }
  }
}

The getS3ComplexObject(..) function checks for these kind of cases recursively [2]. However, due to the above issue, this part of the code never gets executed. Also, it checks for "S3ObjectInput" objects only inside a Map and doesn't check inside List.

@b1zantine b1zantine changed the title SDK deoesn't upload Complex objects to S3 if the input object of a mutation has fields which are implementations of "S3ObjectInput" SDK deoesn't upload Complex objects to S3 if the input object of a mutation has fields which are of type "S3ObjectInput" May 21, 2018
@igormatheus22
Copy link

Same problem here.

@rohandubal
Copy link
Contributor

Hi @SudarAbisheck

Thanks for reporting this. You are right, currently the SDK checking in limited ways about determining if there is complex object present in the mutation. We can surely enhance the checking mechanism.

To make sure we add the right checks, could you elaborate what is your use-case currently? Is the 2nd example which you posted in the issue the exact use-case which you have?

Thanks,
Rohan

@minbi minbi closed this as completed Jun 28, 2018
@b1zantine
Copy link
Author

I can see that issue hasn't been fixed yet. Still, the SDK just checks the query document for the term S3ObjectInput. Some query document need not have this word as part of the query.

request.operation.queryDocument().contains("S3ObjectInput")

The same issue exists in the iOS SDK as well. awslabs/aws-mobile-appsync-sdk-ios#45

@janejjshen
Copy link

Issue still exists - Instead of checking the S3ObjectInput string in the document, we should be looping through the input variables, and check if any is instanceof S3InputObjectInterface. This will be the more flexible approach.

@frankmuellr frankmuellr reopened this Oct 9, 2018
@frankmuellr frankmuellr added AppSync feature-request Request a new feature labels Oct 9, 2018
@scb01 scb01 self-assigned this Oct 12, 2018
@motae99
Copy link

motae99 commented Nov 1, 2018

+1

@frankmuellr frankmuellr changed the title SDK deoesn't upload Complex objects to S3 if the input object of a mutation has fields which are of type "S3ObjectInput" SDK doesn't upload Complex objects to S3 if the input object of a mutation has fields which are of type "S3ObjectInput" Nov 1, 2018
@scb01
Copy link
Contributor

scb01 commented Dec 30, 2018

@SudarAbisheck @igormatheus22 @janejjshen @motae99
I have a PR with bug fixes and code changes that will fix this issue - #89. I am targeting to get this out in the next release of the SDK. I will post back on this thread once the release is out.

@scb01
Copy link
Contributor

scb01 commented Dec 31, 2018

@SudarAbisheck @igormatheus22 @janejjshen @motae99

Version 2.7.3 of the SDK contains the fixes for this issue. Please upgrade to this version and let us know how you it goes.

@scb01 scb01 added the pending-response Issue is pending response from the issue requestor label Dec 31, 2018
@frankmuellr frankmuellr added bug Something isn't working and removed feature-request Request a new feature labels Dec 31, 2018
@janejjshen
Copy link

Seems to work out quite nicely! Thanks!

Need the following code when initializing the AWSAppSyncClient(small modification from the amplify docs), and I do have to manually find and specify the bucket/key attributes, but overall it saves one upload call which is quite nice!

client = AWSAppSyncClient.builder()
                    .context(context)
                    .awsConfiguration(new AWSConfiguration(context))
                    .s3ObjectManager(new S3ObjectManagerImplementation(new AmazonS3Client(AWSMobileClient.getInstance())))
                    .cognitoUserPoolsAuthProvider(new CognitoUserPoolsAuthProvider() {
                        @Override
                        public String getLatestAuthToken() {
                            try {
                                return AWSMobileClient.getInstance().getTokens().getIdToken().getTokenString();
                            } catch (Exception e){
                                Log.e("APPSYNC_ERROR", e.getLocalizedMessage());
                                return e.getLocalizedMessage();
                            }
                        }
                    }).build();

Is there an equivalent way to download an S3 object automatically? Or do I still need to use the TransferUtility and call download explicitly?

@frankmuellr frankmuellr added documentation and removed pending-response Issue is pending response from the issue requestor bug Something isn't working labels Jan 2, 2019
@minbi
Copy link
Contributor

minbi commented Jan 5, 2019

Hi @janejjshen ,

Yes, you will still need to manage the download of the S3 object.

We are closing this issue because there has been confirmation the fix is working. Please feel free to open a new issue if the problem persists. We ask this because closed issues are not actively monitored.

Thanks

@mopilo
Copy link

mopilo commented Jan 6, 2021

I'm really stuck here, after adding this line.s3ObjectManager(new S3ObjectManagerImplementation(new AmazonS3Client(AWSMobileClient.getInstance()))). I still get S3 Upload failed.

@mopilo
Copy link

mopilo commented Jan 6, 2021

com.apollographql.apollo.exception.ApolloException: S3 upload failed. at com.amazonaws.mobileconnectors.appsync.AppSyncComplexObjectsInterceptor.interceptAsync(AppSyncComplexObjectsInterceptor.java:70) at com.apollographql.apollo.internal.interceptor.RealApolloInterceptorChain.proceedAsync(RealApolloInterceptorChain.java:43) at com.amazonaws.mobileconnectors.appsync.InMemoryOfflineMutationObject.execute(InMemoryOfflineMutationObject.java:52) at com.amazonaws.mobileconnectors.appsync.InMemoryOfflineMutationManager.processNextMutation(InMemoryOfflineMutationManager.java:63) at com.amazonaws.mobileconnectors.appsync.AppSyncOfflineMutationManager.processNextInQueueMutation(AppSyncOfflineMutationManager.java:175) at com.amazonaws.mobileconnectors.appsync.AppSyncOfflineMutationInterceptor$QueueUpdateHandler.handleMessage(AppSyncOfflineMutationInterceptor.java:236) at android.os.Handler.dispatchMessage(Handler.java:110) at android.os.Looper.loop(Looper.java:203)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants