
Research
/Security News
Mini Shai-Hulud Campaign Hits Red Hat Cloud Services npm Packages
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.
sails-graphql-glue
Advanced tools
this package is intended to make a glue for express-graphql and sails framework.
to install is just straight forward:
npm i sails-graphql-glueyarn add sails-graphql-glueON api/controllers/graphql.js:
/* api/controllers/graphql.js */
var Promise = require('bluebird');
const { actionAsResolver, serve } = require('sails-graphql-glue');
const typeDefs = `
type Query {
hello: String!
helloName(name: String): String!
}
schema {
query: Query
}
`
const resolvers = {
Query: {
hello: async () => Promise.resolve('hello world!'),
helloName: actionAsResolver(require('./api/hello')),
}
}
module.exports = serve({typeDefs, resolvers, debug: sails.config.environment === 'development'});
ON config/routes.js add the graphql route:
module.exports.routes = {
...
'/graphql': { action: 'graphql' }
};
This function is to wrap sails action2 into a resolver. so you can use your current action freely.
Example: actionAsResolver(require('./api/hello'))
this function is to glue express-graphql into sails compatible.
graphql schemaroot resolversjust to make sure json pretty print, GraphiQL, and full error reportingA Resolver in graphql have this common format:
(parent, args, context, info) => ...
Therefore, to make it compatible with machine inputs,
the parameters changed into $parent, $context, $info.
Parameters from arg extracted into normal machine inputs.
// automatically added into action/machine inputs
{
"$parent": {
description: "parent",
type: 'ref',
defaultsTo: {},
},
"$context": {
description: "context",
type: 'ref',
defaultsTo: {},
},
"$info": {
description: "info",
type: 'ref',
defaultsTo: {},
},
}
you can use context (req), as example:
fn: async ({ $context, name = "test" }) => {
console.log(Object.keys($context));
return name
}
// console:
// [
// ...
// 'headers',
// ...
// 'url',
// ...
// 'query',
// ...
// 'cookies',
// ...
// 'session',
// 'file',
// 'body',
// '_body',
// ...
// ]
module.exports = {
friendlyName: 'Me',
description: 'Get Login Information.',
inputs: {},
exits: {},
fn: async function() {
console.log(this.req.headers)
return ({})
}
};
In those example above, the this.req will be assigned of $context or request object. but in arrow function, it will not. since You cannot "rebind" an arrow function. It will always be called with the context in which it was defined. Just use a normal function.
MIT
FAQs
a glue for express-graphql and sails framework
We found that sails-graphql-glue 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
/Security News
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.

Research
/Security News
The North Korean malware loader hides in a Packagist-listed package and its GitHub branch to fetch and execute remote code in a likely Contagious Interview-style lure.

Security News
The Rust project is moving toward formal rules on LLM use in contributions after months of internal debate over maintainer burden, code quality, and contributor experience.