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
4
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 - npm Package Compare versions

Comparing version 1.0.0-beta.13 to 1.0.0

2

index.js
module.exports = function PgManyToManyPlugin(builder, options) {
builder.hook("build", build => {
builder.hook("build", (build) => {
const pkg = require("./package.json");

@@ -4,0 +4,0 @@

{
"name": "@graphile-contrib/pg-many-to-many",
"version": "1.0.0-beta.13",
"version": "1.0.0",
"description": "Add connection fields for many-to-many relations",

@@ -20,12 +20,12 @@ "main": "index.js",

"devDependencies": {
"eslint": "^6.4.0",
"eslint-config-prettier": "^6.3.0",
"eslint-plugin-jest": "^22.17.0",
"eslint-plugin-prettier": "^3.1.1",
"graphql": "^14.5.7",
"jest": "^24.9.0",
"jest-serializer-graphql-schema": "^4.4.6-alpha.0",
"pg": "^7.12.1",
"eslint": "^7.7.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-jest": "^23.20.0",
"eslint-plugin-prettier": "^3.1.4",
"graphql": "^14.7.0",
"jest": "^26.4.0",
"jest-serializer-graphql-schema": "4.6.0",
"pg": "^7.18.2",
"postgraphile-core": "4.5.0",
"prettier": "1.18.2"
"prettier": "2.0.5"
},

@@ -42,4 +42,4 @@ "jest": {

"engines": {
"node": ">=8.6"
"node": ">=10"
}
}

@@ -1,5 +0,5 @@

const hasNonNullKey = row => {
const hasNonNullKey = (row) => {
if (
Array.isArray(row.__identifiers) &&
row.__identifiers.every(i => i != null)
row.__identifiers.every((i) => i != null)
) {

@@ -49,3 +49,3 @@ return true;

const handleNullRow = pgForbidSetofFunctionsToReturnNull
? row => row
? (row) => row
: (row, identifiers) => {

@@ -81,3 +81,3 @@ if ((identifiers && hasNonNullKey(identifiers)) || hasNonNullKey(row)) {

const junctionTypeName = inflection.tableType(junctionTable);
const base64 = str => Buffer.from(String(str)).toString("base64");
const base64 = (str) => Buffer.from(String(str)).toString("base64");

@@ -106,3 +106,3 @@ const EdgeType = newWithHooks(

usesCursor: [true],
pgQuery: queryBuilder => {
pgQuery: (queryBuilder) => {
if (rightPrimaryKeyAttributes) {

@@ -194,3 +194,3 @@ queryBuilder.selectIdentifiers(rightTable);

const safeAlias = getSafeAliasFromResolveInfo(resolveInfo);
return data.data.map(entry => {
return data.data.map((entry) => {
const record = handleNullRow(

@@ -219,3 +219,3 @@ entry[safeAlias],

const safeAlias = getSafeAliasFromResolveInfo(resolveInfo);
return data.data.map(entry => ({
return data.data.map((entry) => ({
...entry,

@@ -222,0 +222,0 @@ ...entry[safeAlias],

@@ -17,3 +17,3 @@ function arraysAreEqual(array1, array2) {

return leftTable.foreignConstraints
.filter(con => con.type === "f")
.filter((con) => con.type === "f")
.reduce((memoLeft, junctionLeftConstraint) => {

@@ -33,3 +33,3 @@ if (

}
if (omit(junctionTable, "manyToMany")) {
if (omit(junctionTable, "read") || omit(junctionTable, "manyToMany")) {
return memoLeft;

@@ -39,3 +39,3 @@ }

.filter(
con =>
(con) =>
con.id !== junctionLeftConstraint.id && // Don't follow the same constraint back to the left table

@@ -48,2 +48,5 @@ con.type === "f" &&

const rightTable = junctionRightConstraint.foreignClass;
if (omit(rightTable, "read") || omit(rightTable, "manyToMany")) {
return memoRight;
}

@@ -60,6 +63,6 @@ const leftKeyAttributes = junctionLeftConstraint.foreignKeyAttributes;

if (
!leftKeyAttributes.every(_ => _) ||
!junctionLeftKeyAttributes.every(_ => _) ||
!junctionRightKeyAttributes.every(_ => _) ||
!rightKeyAttributes.every(_ => _)
!leftKeyAttributes.every((_) => _) ||
!junctionLeftKeyAttributes.every((_) => _) ||
!junctionRightKeyAttributes.every((_) => _) ||
!rightKeyAttributes.every((_) => _)
) {

@@ -71,6 +74,6 @@ throw new Error("Could not find key columns!");

if (
leftKeyAttributes.some(attr => omit(attr, "read")) ||
junctionLeftKeyAttributes.some(attr => omit(attr, "read")) ||
junctionRightKeyAttributes.some(attr => omit(attr, "read")) ||
rightKeyAttributes.some(attr => omit(attr, "read"))
leftKeyAttributes.some((attr) => omit(attr, "read")) ||
junctionLeftKeyAttributes.some((attr) => omit(attr, "read")) ||
junctionRightKeyAttributes.some((attr) => omit(attr, "read")) ||
rightKeyAttributes.some((attr) => omit(attr, "read"))
) {

@@ -88,15 +91,15 @@ return memoRight;

const junctionLeftConstraintIsUnique = !!junctionTable.constraints.find(
c =>
(c) =>
["p", "u"].includes(c.type) &&
arraysAreEqual(
c.keyAttributeNums,
junctionLeftKeyAttributes.map(attr => attr.num)
junctionLeftKeyAttributes.map((attr) => attr.num)
)
);
const junctionRightConstraintIsUnique = !!junctionTable.constraints.find(
c =>
(c) =>
["p", "u"].includes(c.type) &&
arraysAreEqual(
c.keyAttributeNums,
junctionRightKeyAttributes.map(attr => attr.num)
junctionRightKeyAttributes.map((attr) => attr.num)
)

@@ -112,3 +115,3 @@ );

const allowsMultipleEdgesToNode = !junctionTable.constraints.find(
c =>
(c) =>
["p", "u"].includes(c.type) &&

@@ -118,4 +121,4 @@ arraysAreEqual(

[
...junctionLeftKeyAttributes.map(obj => obj.num),
...junctionRightKeyAttributes.map(obj => obj.num),
...junctionLeftKeyAttributes.map((obj) => obj.num),
...junctionRightKeyAttributes.map((obj) => obj.num),
].sort()

@@ -122,0 +125,0 @@ )

@@ -48,5 +48,5 @@ module.exports = function PgManyToManyRelationEdgeColumnsPlugin(builder) {

// Skip left and right key attributes
if (junctionLeftKeyAttributes.map(a => a.name).includes(attr.name))
if (junctionLeftKeyAttributes.map((a) => a.name).includes(attr.name))
return memo;
if (junctionRightKeyAttributes.map(a => a.name).includes(attr.name))
if (junctionRightKeyAttributes.map((a) => a.name).includes(attr.name))
return memo;

@@ -60,3 +60,3 @@

fieldName,
fieldContext => {
(fieldContext) => {
const { type, typeModifier } = attr;

@@ -84,5 +84,5 @@ const { addDataGenerator } = fieldContext;

addDataGenerator(parsedResolveInfoFragment => {
addDataGenerator((parsedResolveInfoFragment) => {
return {
pgQuery: queryBuilder => {
pgQuery: (queryBuilder) => {
queryBuilder.select(

@@ -118,3 +118,3 @@ getSelectValueForFieldAndTypeAndModifier(

),
resolve: data => {
resolve: (data) => {
return pg2gql(data[fieldName], attr.type);

@@ -121,0 +121,0 @@ },

@@ -93,5 +93,5 @@ module.exports = function PgManyToManyEdgeTablePlugin(

};
addDataGenerator(parsedResolveInfoFragment => {
addDataGenerator((parsedResolveInfoFragment) => {
return {
pgQuery: queryBuilder => {
pgQuery: (queryBuilder) => {
queryBuilder.select(() => {

@@ -110,3 +110,3 @@ const resolveData = getDataFromParsedResolveInfoFragment(

queryOptions,
innerQueryBuilder => {
(innerQueryBuilder) => {
innerQueryBuilder.parentQueryBuilder = queryBuilder;

@@ -125,3 +125,3 @@ const junctionPrimaryKeyConstraint =

];
junctionPrimaryKeyAttributes.forEach(attr => {
junctionPrimaryKeyAttributes.forEach((attr) => {
innerQueryBuilder.orderBy(

@@ -128,0 +128,0 @@ sql.fragment`${innerQueryBuilder.getTableAlias()}.${sql.identifier(

module.exports = function PgManyToManyRelationInflectionPlugin(builder) {
builder.hook("inflection", inflection => {
builder.hook("inflection", (inflection) => {
return Object.assign(inflection, {

@@ -24,3 +24,3 @@ manyToManyRelationByKeys(

]
.map(attr => this.column(attr))
.map((attr) => this.column(attr))
.join("-and-")}`

@@ -49,3 +49,3 @@ );

]
.map(attr => this.column(attr))
.map((attr) => this.column(attr))
.join("-and-")}-list`

@@ -52,0 +52,0 @@ );

@@ -106,5 +106,5 @@ const createManyToManyConnectionType = require("./createManyToManyConnectionType");

};
addDataGenerator(parsedResolveInfoFragment => {
addDataGenerator((parsedResolveInfoFragment) => {
return {
pgQuery: queryBuilder => {
pgQuery: (queryBuilder) => {
queryBuilder.select(() => {

@@ -124,3 +124,3 @@ const resolveData = getDataFromParsedResolveInfoFragment(

queryOptions,
innerQueryBuilder => {
(innerQueryBuilder) => {
innerQueryBuilder.parentQueryBuilder = queryBuilder;

@@ -139,10 +139,12 @@ const rightPrimaryKeyConstraint =

];
rightPrimaryKeyAttributes.forEach(attr => {
innerQueryBuilder.orderBy(
sql.fragment`${innerQueryBuilder.getTableAlias()}.${sql.identifier(
attr.name
)}`,
true
);
});
rightPrimaryKeyAttributes.forEach(
(attr) => {
innerQueryBuilder.orderBy(
sql.fragment`${innerQueryBuilder.getTableAlias()}.${sql.identifier(
attr.name
)}`,
true
);
}
);
innerQueryBuilder.setOrderIsUnique();

@@ -149,0 +151,0 @@ }

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