Open pilsy opened 1 year ago
This need is better served by a small inflection plugin:
import { makeAddInflectorsPlugin } from "graphile-utils";
export const FilterToWherePlugin = makeAddInflectorsPlugin(() => ({
filterType(typeName: string) {
return `${typeName}Where`;
},
filterFieldType(typeName: string) {
return `${typeName}Where`;
},
filterFieldListType(typeName: string) {
return `${typeName}ListWhere`;
},
filterArgumentName() {
return "where";
}
});
The only change needed for this would be adding the new filterArgumentName
inflector and then doing:
const filterArgumentName = inflection.filterArgumentName();
and using that variable in the place of filter
here:
and here:
Many of the changes made in this PR are undesirable; for example changing the smart tag from @omit filter
to @omit <someVariable>
is likely to cause a lot of pain for other plugins. If you want to simplify this PR down to only the few lines mentioned above then I'd definitely consider it.
Where i work we wanted the ability to name the filter "where", so while we migrate from Hasura our queries will not change -- this PR adds this feature via connectionFilterName option