Skip to content

feat(hasura): add support for Hasura JSONB/array operators and arbitr…#7307

Open
sytabaresa wants to merge 1 commit intorefinedev:mainfrom
sytabaresa:main
Open

feat(hasura): add support for Hasura JSONB/array operators and arbitr…#7307
sytabaresa wants to merge 1 commit intorefinedev:mainfrom
sytabaresa:main

Conversation

@sytabaresa
Copy link
Copy Markdown

Description

This PR introduces explicit support for Postgres JSONB and array operators (_contains, _contained_in, _has_key, _has_keys_any, and _has_keys_all) to the @refinedev/hasura data provider. Additionally, it adds robust fallback handling for arbitrary generic operators.

PR Checklist

Bugs / Features

What is the current behavior?

Currently, trying to use essential JSONB or array operators in filters causes the data provider to throw an "Operator X is not supported" error. Users are restricted to a highly specific subset of CrudOperators available in the core library mapping, limiting their ability to interface fully with Hasura's rich querying syntax.

What is the new behavior?

The hasuraFilters mapping and generateFilters.ts now officially support the missing JSONB/array operators.
Furthermore, instead of explicitly throwing errors on unrecognized operators, the generateNestedFilterQuery function now gracefully passes arbitrary operators through to the query payload. It intelligently acts as a fallback layer, attaching a _ prefix if needed, ensuring developers can invoke Custom Hasura Operations seamlessly out-of-the-box.

Notes for reviewers

Tested cases covering objects and array filters for the new _contains / _contained_in operators were added in generateFilters.spec.ts.

@sytabaresa sytabaresa requested a review from a team as a code owner February 26, 2026 13:43
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Feb 26, 2026

🦋 Changeset detected

Latest commit: a1a97fc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@refinedev/hasura Minor

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

Copy link
Copy Markdown
Member

@alicanerdurmaz alicanerdurmaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @sytabaresa, thanks for the PR! JSONB/array operator support is a good addition.

A few things:

  1. The fallback is a breaking change

Previously, unknown operators threw an error (throw new Error("Operator X is not supported")). Now they silently pass through. Users who rely on catching this error will break. Was this intentional? If so, the changeset should be major, not minor. But we don't want to release major just for this.

I'd prefer keeping the error for unknown operators. If someone needs a custom operator, they can extend the hasuraFilters map.

  1. Missing tests for generateNestedFilterQuery

Tests were added for handleFilterValue only. Can you add tests for the new JSONB operators going through generateNestedFilterQuery too?

  1. Small typo

"Hashura" in the docs should be "Hasura".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants