Skip to content

Commit 93a2e92

Browse files
committed
feat: add context to custom filters
2 parents 6253d51 + 8560731 commit 93a2e92

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

packages/dataprovider/src/buildVariables/buildWhere.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ const getFilters = (
253253
);
254254
const { originalKey, key, comparator } = processKey(_key);
255255
if (context.options.filters?.[originalKey]) {
256-
return context.options.filters[originalKey](value) ?? {}; // null values are transformed to empty objects
256+
return context.options.filters[originalKey](value, context) ?? {}; // null values are transformed to empty objects
257257
}
258258
if (key === "NOT" || key === "OR" || key === "AND") {
259259
return {

packages/dataprovider/src/types.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010

1111
import { DocumentNode } from "graphql";
1212
import { Resource } from "./constants/interfaces";
13+
import { BuildVariablesContext } from "./buildVariables/types";
1314

1415
export type WhiteListFragment = {
1516
type: "whitelist";
@@ -90,7 +91,10 @@ export type ConfigOptions = {
9091
};
9192
aliasPrefix?: string;
9293
filters?: {
93-
[filterName: string]: (value: any) => Filter | void;
94+
[filterName: string]: (
95+
value: any,
96+
context: BuildVariablesContext,
97+
) => Filter | void;
9498
};
9599
customizeInputData?: CustomizeInputData;
96100
introspection?: IntrospectionOptions;

0 commit comments

Comments
 (0)