Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
@graphile-contrib/pg-many-to-many
Advanced tools
Add connection fields for many-to-many relations
This Graphile Engine plugin adds connection fields for many-to-many relations.
Requires
postgraphile@^4.1.0
orgraphile-build-pg@^4.1.0
Example:
{
allPeople {
nodes {
personName
# 👇 many-to-many relation
teamsByTeamMemberPersonIdAndTeamId {
nodes {
teamName
}
}
}
}
}
Append this plugin and the additional fields will be added to your schema.
yarn add postgraphile
yarn add @graphile-contrib/pg-many-to-many
npx postgraphile --append-plugins @graphile-contrib/pg-many-to-many
const express = require("express");
const { postgraphile } = require("postgraphile");
const PgManyToManyPlugin = require("@graphile-contrib/pg-many-to-many");
const app = express();
app.use(
postgraphile(process.env.DATABASE_URL, "app_public", {
appendPlugins: [PgManyToManyPlugin],
graphiql: true,
})
);
app.listen(5000);
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
Add connection fields for many-to-many relations
The npm package @graphile-contrib/pg-many-to-many receives a total of 1,071 weekly downloads. As such, @graphile-contrib/pg-many-to-many popularity was classified as popular.
We found that @graphile-contrib/pg-many-to-many demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
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.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.