-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
fix: improve Supabase liveProvider filter handling #6573
base: next
Are you sure you want to change the base?
fix: improve Supabase liveProvider filter handling #6573
Conversation
…nd configurable meta.realtimeFilter
🦋 Changeset detectedLatest commit: 19d371f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for refine-doc-live-previews ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @OmkarBansod02 thanks for the updates. Did you test this one locally? Would be nice to have a screen recording with devtools enabled to see if this works as expected.
Hey @BatuhanW , I have tested the changes from the PR locally, and it appears to be working fine. Below are the screen recordings demonstrating the behavior with both a single filter and multiple filters:
single.filter.mp4
multiple.Filters.mp4In the case of multiple filters, as expected, the system logs a warning and uses only the first filter. This matches the intended behavior outlined in the PR. However, I didn't observe the WebSocket error mentioned in the issue description it's possible I may have missed something. Please take a look and let me know if there are any other scenarios I should test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @OmkarBansod02
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for PR @OmkarBansod02, left couple of comments.
@@ -7,6 +7,8 @@ import type { | |||
import { liveTypes, supabaseTypes } from "../types"; | |||
import { mapOperator } from "../utils"; | |||
|
|||
const supportedOperators = ["eq", "neq", "gt", "lt", "gte", "lte"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"neq"
is not a valid operator in Refine. We use "ne"
instead. Please check mapOperator
utility to confirm. This variable can have CrudFilters[]
type defined for safety.
console.warn( | ||
"Warning: Multiple filters detected. Supabase Realtime currently supports only a single filter. The first filter will be applied. To customize this behavior, use the 'meta.realtimeFilter' property.", | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This always logs a warning even if meta.realtimeFilter
is set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please consider using warn-once
with a proper key (resource
can be used) to prevent polluting user console.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've implemented warnOnce
for the multiple filter warning and tested it locally. Here's a screen recording of the behavior, let me know if this aligns with what you were expecting!
Screen.Recording.2025-01-01.231040.mp4
.changeset/shiny-panthers-nail.md
Outdated
fix: handle multiple filters in Supabase liveProvider. | ||
This update addresses the handling of multiple filters in the Supabase liveProvider. It ensures only the first filter is applied and introduces a configurable `meta.realtimeFilter` option for custom filter behavior. A warning is logged when multiple filters are detected. | ||
|
||
Resolves [#6360](https://github.com/refinedev/refine/issues/6360) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolves [#6360](https://github.com/refinedev/refine/issues/6360) | |
[Resolves #6360](https://github.com/refinedev/refine/issues/6360) |
if ("field" in filter) { | ||
if ( | ||
"field" in filter && | ||
supportedOperators.includes(filter.operator) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also needs to be logged if unsupported filters are used.
… meta.realtimeFilter is set
hey @aliemir I’ve made the changes you suggested in the comments and tested them locally. Let me know if this meets your expectations or if any further changes are required! Screen.Recording.2025-01-02.135941.mp4 |
…filter operators cleanly
PR Checklist
Please check if your PR fulfills the following requirements:
Bugs / Features
What is the current behavior?
Supabase Realtime doesn't support multiple filters, causing errors in requests when more than one filter is used.
What is the new behavior?
Supabase Realtime handles one filter at a time, logs a warning for multiple filters, and allows overriding the filter with
meta.realtimeFilter
for more control.fixes #6360
Notes for reviewers
I’ve made the changes as discussed in the issue and added support for handling single filters in the Supabase liveProvider. Please take a look at the implementation and let me know if any further adjustments are needed.