@axinom/pg-grouped-attributes-plugin
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

PgGroupedAttributesPlugin

About

This package contains a plugin written for Postgraphile version 5.

When it's unnecessary to add one-to-one relationship but you still want create a group of attributes looks like an object type in GraphQL, this plugins comes to the rescue.

Let's say you have a table called posts with following columns.

id title description

Then you want to have a group columns to add meta tags of the posts. You could add a one-to-one table or add the columns to the same table above like below.

id title description og__title og__description og__image og__url

Without the plugin, Postgraphile will generate the GraphQL schema like below.

query Query ($id: String!) {
    post (id: $id) {
        id
        title
        description
        ogTitle
        ogDescription
        ogImage
        ogUrl
    }
}

But with the plugin in place, you can have it like this.

query Query ($id: String!) {
    post (id: $id) {
        id
        title
        description
        og {
            title
            description
            image
            url
        }
    }
}

Package Sidebar

Install

npm i @axinom/pg-grouped-attributes-plugin

Weekly Downloads

114

Version

0.0.1

License

MIT

Unpacked Size

33.4 MB

Total Files

368

Last publish

Collaborators

  • ruwanx
  • axinomnpm
  • schwendner
  • axinom_kuzmin
  • axinom_maegi