-
Notifications
You must be signed in to change notification settings - Fork 891
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
Generated API.swift sends mimeType and localUri from S3ObjectTypeInput with mutation. #1740
Comments
@kaustavghosh06 thanks! @yuth Let me know if you need more clarification on this. It's a bit complicated since most people who are currently using this have probably gone ahead and added the It would be really nice if the iOS Codegen + generated swift code could detect if the Thanks! |
Not sure what I did to unassign @yuth there ☝️ 🤷♂ |
@palpatim is there some thing that SDK can do to remove |
If the fields are code-generated, they'll be included in the request automatically, but the SDK doesn't do any field-level filtering. I wouldn't really want us to be in that business in any case--once we start inspecting fields at the SDK level, we run into all kinds of problems with potentially inconsistent behaviors across app versions, platforms, etc, not to mention the cognitive burden of remembering where the magic is actually happening. I think the right behavior here is to edit the schema to remove @yuth does that match your understanding? |
Opened aws-amplify/docs#866 to clarify the expected behavior |
Currently it isn't necessary to add It would be great if they were added in swift, but not sent with the GraphQL request unless they are actually specified in the schema. Does that make sense? |
I should clarify that when I say "schema" I'm referring to the amplify file, not the codegen'd file. |
@cjmartin Thanks for the clarification. The issue we're wrestling with is that the AppSync programming model is very much geared toward using the code-generated objects all up and down the chain. Adding special case logic to the serializer for just that object type makes me uncomfortable. And wouldn't really be the right solution in 100% of the cases; it's conceivable that some app may actually want the At this point, I'm of the opinion that the right solution for this is going to involve the amplify CLI generating resolvers that understand how to ignore those fields by default and not throw validation errors if the incoming objects contain them. I'm discussing this with @yuth and will update this issue when we have more info. |
I'm faced with this issue also. Presume I have to add S3ObjectInput to my API schema like so for now?
|
Thanks for opening this feature request. We recommend using the API (GraphQL) category in Amplify Swift for this -- for more information, please visit https://docs.amplify.aws/swift/build-a-backend/graphqlapi/ Specifically, the Working with files section is relevant for your request. Thanks! |
Describe the bug
I've added storage to my amplify project, and wired it into my GraphQL API as described in the docs, by adding an S3Object type to my schema.
As expected, this adds the S3Object type to the schema in AppSync, along with it's associated S3ObjectInput.
The generated API.swift file correctly generates the S3ObjectInput struct, including
mimeType
andlocalUri
which are needed for AppSync to perform an upload in in conjunction with a mutation on an item containing an S3Object.So far, so good.
However, when a migration is run on an item containing an s3Object using s3ObjectInput, the
mimeType
andlocalUri
are also sent to AppSync with the mutation. The file upload completes successfully, but the mutation fails with an error since AppSync isn't expecting mimeType or localUri (as expected).It looks like this might not have been an issue so much in the past, as most of the older attempts at getting this to work included manually defining the S3Object and S3ObjectInput, and including the
mimeType
andlocalUri
in S3ObjectInput. This would be combined with logic in the resolver to not include these values when writing to the DB, or simply storing everything (awslabs/aws-mobile-appsync-sdk-ios#279 (comment)).Due to another bug (aws-amplify/amplify-cli#1903) this can't be used as a solution, even if it's not the best solution anyway.
To Reproduce
Create an Amplify iOS project with API and Storage, add an S3Object to your schema, push + codegen, upload a file in the iOS app.
Expected behavior
The generated API.swift should include
mimeType
andlocalUri
in S3ObjectInput to handle the file upload, but not pass those values on to the GraphQL mutation.The text was updated successfully, but these errors were encountered: