Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@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.
You can also override individual field names using @manyToManyFieldName
and @manyToManySimpleFieldName
smart comments:
comment on constraint team_member_team_id_fkey on p.team_member is E'@manyToManyFieldName teams';
This changes the GraphQL field name from teamsByTeamMemberTeamId
to teams
.
FAQs
Add connection fields for many-to-many relations
The npm package @graphile-contrib/pg-many-to-many receives a total of 4,281 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.