Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ class QueryRef<Data, Variables> extends OperationRef<Data, Variables> {
_serverStreamSubscription?.cancel();
_serverStreamSubscription = null;
_serverStream = null;
_streamController = null;
}

Stream<QueryResult<Data, Variables>> subscribe() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class FirebaseDataConnect extends FirebasePlugin {
if (ref != null) {
return ref;
} else {
return QueryRef<Data, Variables>(
final newRef = QueryRef<Data, Variables>(
this,
operationName,
transport!,
Expand All @@ -153,6 +153,8 @@ class FirebaseDataConnect extends FirebasePlugin {
varsSerializer,
vars,
);
_queryManager.trackedQueries[queryId] = newRef;
return newRef;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,5 +254,38 @@ void main() {
expect(routingTransport.websocket.auth, equals(mockAuth));
expect(routingTransport.websocket.appCheck, equals(mockAppCheck));
});

test('query returns identical QueryRef instance for identical queries', () {
final dynamicApp = DynamicMockFirebaseApp(
name: 'queryRefAppName',
options: const FirebaseOptions(
apiKey: 'fake_api_key',
appId: 'fake_app_id',
messagingSenderId: 'fake_messaging_sender_id',
projectId: 'fake_project_id',
),
);

final instance = FirebaseDataConnect(
app: dynamicApp,
connectorConfig: mockConnectorConfig,
);

final ref1 = instance.query(
'listMovies',
(json) => json,
emptySerializer,
null,
);

final ref2 = instance.query(
'listMovies',
(json) => json,
emptySerializer,
null,
);

expect(identical(ref1, ref2), isTrue);
});
});
}
Loading