File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed
Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -120,7 +120,7 @@ class GraphQLCache extends NormalizingDataProxy {
120120 for (final patch in optimisticPatches) {
121121 if (patch.data.containsKey (rootId)) {
122122 final patchData = patch.data[rootId];
123- if (value is Map <String , Object > && patchData is Map <String , Object >) {
123+ if (value is Map <String , dynamic > && patchData is Map <String , dynamic >) {
124124 value = deeplyMergeLeft ([
125125 value,
126126 patchData,
Original file line number Diff line number Diff line change @@ -198,6 +198,41 @@ void main() {
198198 },
199199 );
200200
201+ test (
202+ 'readNormalized returns correctly merged optimistic data' ,
203+ () {
204+ cache.recordOptimisticTransaction (
205+ (proxy) => proxy
206+ ..writeQuery (
207+ basicTest.request,
208+ data: basicTest.data,
209+ ),
210+ '1' ,
211+ );
212+
213+ expect (cache.optimisticPatches.length, 1 );
214+ expect (cache.readNormalized ("C:6" ),
215+ equals ({'cField' : 'value' , '__typename' : 'C' , 'id' : 6 }));
216+
217+ cache.writeNormalized ('C:6' , {
218+ '__typename' : 'C' ,
219+ 'id' : 6 ,
220+ "score" : null ,
221+ });
222+
223+ expect (cache.readNormalized ("C:6" , optimistic: false ),
224+ equals ({'__typename' : 'C' , 'id' : 6 , 'score' : null }));
225+ expect (
226+ cache.readNormalized ("C:6" , optimistic: true ),
227+ equals ({
228+ '__typename' : 'C' ,
229+ 'id' : 6 ,
230+ 'cField' : 'value' ,
231+ 'score' : null
232+ }));
233+ },
234+ );
235+
201236 recordCFragmentUpdate (GraphQLCache cache) =>
202237 cache.recordOptimisticTransaction (
203238 (proxy) => proxy
You can’t perform that action at this time.
0 commit comments