New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@graphile-contrib/pg-many-to-many

Package Overview
Dependencies
Maintainers
3
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphile-contrib/pg-many-to-many

Add connection fields for many-to-many relations

  • 1.0.0-beta.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.6K
increased by10.28%
Maintainers
3
Weekly downloads
 
Created
Source

@graphile-contrib/pg-many-to-many

This Graphile Engine plugin adds connection fields for many-to-many relations.

Example:

{
  allPeople {
    nodes {
      personName
      # 👇 many-to-many relation
      teamsByTeamMemberPersonIdAndTeamId {
        nodes {
          teamName
        }
      }
    }
  }
}

Installation

yarn add @graphile-contrib/pg-many-to-many

Requires postgraphile@^4.1.0-rc.2 or graphile-build-pg@^4.1.0-rc.2

Usage

Append this plugin and the additional fields will be added to your schema.

Usage - CLI

postgraphile --append-plugins @graphile-contrib/pg-order-by-related -c postgres:///my_db

Usage - Library

const express = require("express");
const { postgraphile } = require("postgraphile");
const PgManyToMany = require("@graphile-contrib/pg-many-to-many");

const app = express();

app.use(
  postgraphile(process.env.DATABASE_URL, "app_public", {
    appendPlugins: [PgManyToMany]
  })
);

app.listen(process.env.PORT || 3000);

Inflection

To avoid naming conflicts, this plugin uses a verbose naming convention (e.g. teamsByTeamMemberTeamId), similar to how related fields are named by default in PostGraphile v4.

You can override this by adding an inflector plugin. For example, the following plugin shortens the names to just the table name (producing e.g. teams):

const { makeAddInflectorsPlugin } = require("graphile-utils");

module.exports = makeAddInflectorsPlugin(
  // TODO
);

See the makeAddInflectorsPlugin documentation for more information.

FAQs

Package last updated on 26 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc