Skip to content

feat(core): convert MetaQuery and GraphQLQueryOptions to interfaces - #7531

Open
Bugrabugra wants to merge 1 commit into
refinedev:mainfrom
Bugrabugra:feat/meta-query-declaration-merging
Open

feat(core): convert MetaQuery and GraphQLQueryOptions to interfaces#7531
Bugrabugra wants to merge 1 commit into
refinedev:mainfrom
Bugrabugra:feat/meta-query-declaration-merging

Conversation

@Bugrabugra

@Bugrabugra Bugrabugra commented Aug 7, 2026

Copy link
Copy Markdown

Both types were plain type aliases, which prevented consumers from using TypeScript's declaration merging to extend MetaQuery with app-specific fields (e.g. meta.queryParams read by custom data providers). Converting them to interfaces is structurally identical and fully backward compatible, but unlocks:

declare module "@refinedev/core" {
  interface MetaQuery {
    queryParams?: { _pull?: string };
  }
}

Fixes #7527

PR Checklist

  • The commit message follows our guidelines

Bugs / Features

  • Related issue(s) linked
  • Tests for the changes have been added
  • Docs have been added / updated
  • Changesets have been added

What is the current behavior?

MetaQuery and GraphQLQueryOptions are plain type aliases. Because type aliases can't be extended via TypeScript's declaration merging, consumers have no way to add typed fields to meta (e.g. meta.queryParams, read by most custom data providers to build query strings). Every key on meta is typed as any, so typos and shape mismatches go uncaught.

What is the new behavior?

Converted both to interfaces (MetaQuery extends QueryBuilderOptions, GraphQLQueryOptions). This is structurally identical and fully backward compatible, but it unlocks declaration merging:

declare module "@refinedev/core" {
  interface MetaQuery {
    queryParams?: { _pull?: string; [key: string]: unknown };
  }
}

...giving autocompletion/type-checking for custom meta fields across every hook (useTable, useShow, useList, etc.) without wrapper hooks or per-call-site casting.

fixes #7527

Notes for reviewers

This is a type-only change with no behavioral difference, so I didn't add a new runtime test (the package has no type-level test infrastructure like tsd/expectTypeOf). Verified instead by:

  • pnpm build (incl. .d.ts generation) passing with zero errors for core, hasura, strapi-v4, and ui-types (all packages that reference MetaQuery/GraphQLQueryOptions)
  • Full core test suite: 122 files / 1213 tests passing
  • A manual smoke test confirming declaration merging works end-to-end (extended field gets autocompletion, wrong-typed value is rejected by tsc)

Both types were plain type aliases, which prevented consumers from
using TypeScript's declaration merging to extend MetaQuery with
app-specific fields (e.g. meta.queryParams read by custom data
providers). Converting them to interfaces is structurally identical
and fully backward compatible, but unlocks:

declare module "@refinedev/core" {
  interface MetaQuery {
    queryParams?: { _pull?: string };
  }
}

Fixes refinedev#7527
@changeset-bot

changeset-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 43d4ed9

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

This PR includes changesets to release 1 package
Name Type
@refinedev/core 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

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.

[FEAT] Make MetaQuery an interface to support declaration merging

1 participant