-
Notifications
You must be signed in to change notification settings - Fork 80
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
Cannot Return null for non-nullable type: 'String' within Parent (Error while adding a new field in the Schema) #998
Comments
Hey @arunks18 👋 thanks for raising this! From the issue's overview I see this is only happening after making changes. Is it possible that the index has yet to be backfilled when executing the query? Can you confirm whether this continues to occur after some time? How are you adding this new field to the schema? |
@josefaidt This issue is not related to indexing / Open search, even for those types which we have not included in @searchable / indexing it still shows the same error. For example, check the below type/schema, it also has the same issue. type location
@model
@auth(
rules: [
{ allow: public, operations: [read] }
{ allow: private, operations: [read, update, create] }
{
allow: groups
groups: ["Admin"]
operations: [create, update, read, delete]
}
]
) {
id: ID!
name: String! # name
gender: String! # Gender type MALE / FEMALE
city: String!
state: String!
} Kindly try adding a new field to the above schema and try updating the new field using a Backend Lambda function using mutation. the new field gets updated. Now Try getting the updated data using Subscription / Query from any Frontend/ Amplify. I think there is a problem with the resolver which is sending the data as NULL. |
@josefaidt any update regarding this issue ? |
@josefaidt We are still waiting for the update, eagerly waiting for this ! |
Hey @arunks18 👋 apologies for the delay here! There was a recent update to the Amplify CLI that enables runtime filtering, can you try upgrading your CLI and recompiling the schema to test? Afterwards, if the issue still occurs please try removing the auth rules from the schema and push to test. |
Updating the CLI did not work but we found the solution ourselves using the below link, https://blog.purple-technology.com/lessons-learned-aws-appsync-subscriptions/
The point is that even though your lambda resolver is returning values for all the mutation fields, an AppSync subscription is only seeing the mutation fields which were selected in the mutation request. This is probably caused by the fact that resolver doesn't have to return values for fields which are not requested in the mutation request. The issue is prevalent when schema's Fields are mandated to have some value and null not allowed. Once it is mandated the entire result set is returned as Null which should not be the case, it must be null only for the field which was not mentioned in the Mutation Query. Thank you for your Help @josefaidt . |
Before opening, please confirm:
How did you install the Amplify CLI?
npm
If applicable, what version of Node.js are you using?
16.17.1
Amplify CLI Version
10.2.1
What operating system are you using?
Mac
Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
No manual changes made
Amplify Categories
api
Amplify Commands
Not applicable
Describe the bug
While using a Lambda function to update using the mutation in GraphQL, the data gets updated but on subscribing it the data shows up as NULL. This Issue happens only when i make a change in the schema by adding a new Field / Column. This issue does not happen when i don't make any changes in the existing schema. Note that i am using @searchable.
Expected behavior
when i make a change in the schema by adding a new Field / Column and I use a Lambda function to update data using the mutation in GraphQL, the data gets updated and on subscribing it the updated new data must show.
Reproduction steps
GraphQL schema(s)
Project Identifier
No response
Log output
The text was updated successfully, but these errors were encountered: