firebase / firebase/firebase-js-sdk

Provide a way to serialize Query (expose stringifyQuery for example)

Open
#6,787 5 comments 3 reactions 1 assignee Claimed by @MarkDuckworth View on GitHub
api: firestore needs-attention question
Dominant language
TypeScript
Stars
5.1k
Forks
1k
Avg merge
2d 21h
Merged PRs (30d)
37

Description

### [REQUIRED] Describe your environment

* Operating System version: Windows 11
* Browser version: EDGE 107.0.1418.42
* Firebase SDK version: 9.14.0
* Firebase Product: Firestore

### [REQUIRED] Describe the problem
When hydrating (angular universal, next.js, ...) / resuming (qwik) the frontend, frameworks serialize the state of the application as a json object in the html. It works well for document & collection reference as we can use the `path` as a serializable reference, but not for Query. This leads to a flickering on the application if the page display data coming from a query.

### Solution
Provide a way to serialize a query so it can be referenced in the backend & frontend the same way.
I saw in the code that there is a `stringifyQuery` that transforms a query into a string. If exposed, it would fix this issue. For example:
```typescript
const ref = collection('collectionName');
const queryRef = query(ref, where('field', '==', value));
const key = stringifyQuery(queryRef);
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.