JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 53531
  • Score
    100M100P100Q177087F
  • License MIT

Simplifies the graphile-build-pg inflector to trim the `ByFooIdAndBarId` from relations

Package Exports

  • @graphile-contrib/pg-simplify-inflector

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@graphile-contrib/pg-simplify-inflector) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@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,
    ],
    // ... other settings ...
  })
);

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';