@graphile-contrib/pg-simplify-inflector
Simplifies relation names; e.g. postsByAuthorId
becomes simply posts
.
Installation:
yarn add @graphile-contrib/pg-simplify-inflector
or
npm install --save @graphile-contrib/pg-simplify-inflector
Usage:
CLI:
postgraphile --append-plugins @graphile-contrib/pg-simplify-inflector
Library:
const PgSimplifyInflectorPlugin =
require('@graphile-contrib/pg-simplify-inflector');
app.use(
postgraphile(process.env.AUTH_DATABASE_URL, "app_public", {
appendPlugins: [
PgSimplifyInflectorPlugin,
],
})
);
Handling field conflicts:
If you have two relations that will result in a conflict (e.g.
postsByAuthorId
and postsByEditorId
would both become posts
with this
plugin) then you will need to rename one of them - you can do so using smart
comments, e.g.:
comment on constraint posts_editor_id_fkey on posts is
E'@foreignFieldName editedPosts\n@fieldName editor';