-
Notifications
You must be signed in to change notification settings - Fork 249
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
[api] Model helpers should not pass null
fields
#2492
Comments
I made a PR for this. Noted in the PR description but IMO we should not remove all null values from mutation input (plenty of valid use cases for doing that), only null values when they are owner fields. |
I faced the same issue for my model:
And
So instead of a json without the |
@ragingsquirrel3 Is there a workaround before your fix? |
@okhomin yes there is a workaround. You basically have to remove the unwanted keys from the request input variables and copy to a new request like this: final Blog blog = Blog(id: id, name: name);
final GraphQLRequest<Blog> req = ModelMutations.create<Blog>(blog);
final modifiedInputVariables =
req.variables['input'] as Map<String, dynamic>;
modifiedInputVariables.remove('owners');
final modifiedVariables = {'input': modifiedInputVariables};
final modifiedRequest = GraphQLRequest<Blog>(
document: req.document,
decodePath: req.decodePath,
modelType: req.modelType,
variables: modifiedVariables,
);
final operation = Amplify.API.query(request: modifiedRequest); Quick followup question: Is your use case a create mutation with |
Update as of today, I was experiencing this issue with the stable release (v0.6.12). However I switched to the developer preview version (v1.0.0-next.4). I can confirm that the issue is still happening in the stable release but the dev preview is fine. I guess I will be sticking to the working version. |
This issue has been addressed in v1.0.0 of Amplify Flutter, which is now stable. This release also includes web and desktop support for Auth, API, Analytics, and Storage. You can see the list of new features and bug fixes in the release notes, and see more details on how to migrate in the upgrade guide. |
I have the same problem with amplify_flutter=1.3.1. Is this is a bug? |
Hi @maziarzamani. Would you be able to create a new issue with details about your schema and the issue you're facing? |
I am actually on a AWS Support right now, as I was able to fix it again by removing the field-level restriction, so there is definitely something weird going on in the SDK. |
Long story short, it seems to be a bug in the SDK, if any AWS personnel needs a reference to the case ID, please let me know. I'd really love if this bug was fixed as I have many read-only field permission in my GraphQL schema. |
Description
AppSync interprets explicit
null
values different than implicit ones in thevariables
map of a request. Model helpers explicitly setting these values can lead to unexpected errors when these fields are read-only or otherwise protected.For example, consider the schema:
And a mutation to create a
Todo
:The following input allows creation with no issues:
However, model helpers generates the following input (notice the inclusion of
owners
which cannot be written to):This leads to the following error:
Categories
Steps to Reproduce
No response
Screenshots
No response
Platforms
Android Device/Emulator API Level
No response
Environment
Dependencies
Device
N/A
OS
N/A
Deployment Method
Amplify CLI
CLI Version
No response
Additional Context
No response
Amplify Config
N/A
The text was updated successfully, but these errors were encountered: