
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
graphql-bookshelf
Advanced tools
This is an early version of the BookshelfType I wrote to help me link up my Bookshelf models (built on top of Postgres) to my GraphQL schema.
npm install --save graphql-bookshelf
...
var BookshelfType = require('graphql-bookshelf');
Use BookshelfType inside of GraphQLObjectType...
export default new GraphQLObjectType(BookshelfType({
name: 'Classroom',
description: 'Need I say more?',
// ...and an object gets passed into the fields to help with your model.
fields: (model) => ({
Simply wrap with model.attr()...
id: model.attr({
type: new GraphQLNonNull(GraphQLInt),
description: 'The id of the classroom.',
// ...and you don't need to resolve table attributes.
}),
Or wrap with model.belongsTo()...
subject: model.belongsTo({
type: SubjectType, // And use the right association type...
description: 'The subject of the classroom.',
// And you get one-to-one relationships for free
}),
Use model.hasMany()...
students: model.hasMany({
type: new GraphQLList(StudentType), // And make sure you use `GraphQLList`
description: 'Students in the classroom.',
// Now you have associated collections for free
}),
Need to do more on your associated collection?
homeworks: model.hasMany({
type: new GraphQLList(HomeworkType),
description: 'Homework submitted to the classroom (latest to oldest).',
// Define a resolve function...
resolve: (qb) => {
// And get a sweet KnexJS query builder
qb.orderBy('created_at', 'DESC');
}
}),
Or just leave it alone...
size: {
type: GraphQLInt,
description: 'How many students there are in the class.',
resolve: (model) => {
// And do it the old fashioned way
return model.studentCount();
},
}
}),
}));
Are you using graphql-relay-js? Define some connection associations.
At the top:
import { connectionDefinitions, connectionArgs } from "graphql-relay";
And in your schema...
homeworks: model.hasMany({
type: connectionDefinitions({nodeType: HomeworkType}).connectionType,
args: connectionArgs,
description: 'Homework submitted to the classroom.'
}),
This library is intended to keep it simple. Automatic generation of schema can leave use-cases out, while using bookshelf in every resolve calls for large amounts of repetitive boilerplate.
Another thing this library could help with is optimization. Turing graphql queries into database calls can be expensive, but using a layer in between can help make those optimizations that would get ugly and repetitive in every resolve.
See this example in action via the tests...
sqlite3 graphql_bookshelf.sqliteknex migrate:latestnpm testFAQs
Some help defining schema around bookshelfjs models.
The npm package graphql-bookshelf receives a total of 118 weekly downloads. As such, graphql-bookshelf popularity was classified as not popular.
We found that graphql-bookshelf demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.

Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.

Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.

Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.