observeQuery does not return an updated items array when a model has been mutated
See original GitHub issueBefore opening, please confirm:
- I have searched for duplicate or closed issues and discussions.
- I have read the guide for submitting bug reports.
- I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
JavaScript Framework
React
Amplify APIs
DataStore
Amplify Categories
Not applicable
Environment information
System:
OS: macOS 12.0.1
CPU: (6) x64 Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz
Memory: 15.88 GB / 64.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.13.1 - ~/.nvm/versions/node/v16.13.1/bin/node
Yarn: 1.22.1 - /usr/local/bin/yarn
npm: 8.1.2 - ~/.nvm/versions/node/v16.13.1/bin/npm
Browsers:
Chrome: 96.0.4664.93
Firefox: 94.0.2
Safari: 15.1
npmPackages:
@sermonary/components: ^0.3.29 => 0.3.29
@sermonary/theme: ^0.3.29 => 0.3.29
@types/node: ^12.0.0 => 12.20.15
npmGlobalPackages:
corepack: 0.10.0
npm: 8.1.2
Describe the bug
The ObserveQuery
API is not returning the updated items when a single model has been mutated. For example, if I am querying and subscribing to model updates like DataStore.observeQuery(Sermon)
, new items are only emitted for CREATE and DELETE. Updated items are not being emitted when updating a single model in the list, and thus causes my query to be stale and does not reflect what is actually in the DataStore or in the DB.
Expected behavior
I would expect any change to a model to emit a message and cause observeQuery
to return a new array of items with the updated model in the response.
Reproduction steps
- Observe a model query with
DataStore.observeQuery()
- Perform a mutation with
DataStore.save()
on a model that currently exists and was returned by theobserveQuery
method. - Note that the items are not updated from
DataStore.observeQuery()
Code Snippet
// Put your code below this line.
Log output
// Put your logs below this line
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
How to modify AWS Datastore ObserveQuery model result
I tried to modify mutations, queries and subscriptions model generated by Codegen but no success. Here is the output I am looking for...
Read more >Announcing custom primary key support for AWS Amplify ...
Today, we are introducing the release of custom primary keys, also known as custom identifiers, for Amplify DataStore to provide additional ...
Read more >A persistent data structure is one that shares structure with other ...
From the outside, get_x(version1) still returns the same value before and after the update, but the data structure it refers to has been...
Read more >DataStore - Manipulating data - JavaScript - AWS Amplify Docs
Models in DataStore are immutable. To update a record you must use the copyOf function to apply updates to the item's fields rather...
Read more >MutationObserver.observe() - Web APIs - MDN Web Docs
A DOM Node (which may be an Element ) within the DOM tree to watch ... DOM mutations should be reported to mutationObserver...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It’s a pretty simple handler to update a Sermon model on a single sermon view page and then going back to the sermon list screen, the list hasn’t updated because the Update snapshot hasn’t been sent to observeQuery.
This issue has been automatically locked since there hasn’t been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server
*-help
channels or Discussions for those types of questions.