Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
joinMonster
✓ import joinMonster from 'join-monster'
✗ const joinMonster = require('join-monster')
joinMonster is a default export; CJS require also works but ESM is preferred since v4.
joinMonster
✓ import joinMonster from 'join-monster'
✗ import { joinMonster } from 'join-monster'
Named export 'joinMonster' does not exist; it's a default export.
default
✓ import joinMonster from 'join-monster'
✗ import * as joinMonster from 'join-monster'
Star import works but yields { default: ... }; default import is simpler.
joinMonster.default
✓ const jm = require('join-monster').default
✗ const jm = require('join-monster')
When using CJS, .default is needed because the module is an ESM default export.
JoinMonsterOptions
✓ import type { JoinMonsterOptions } from 'join-monster'
Type imports are available for TypeScript users.
Creates an Express server with a GraphQL endpoint using joinMonster to resolve a 'user' query that joins 'users' table and virtual fields.
import express from 'express';
import { graphqlHTTP } from 'express-graphql';
import { GraphQLSchema, GraphQLObjectType, GraphQLString, GraphQLInt } from 'graphql';
import joinMonster from 'join-monster';
const app = express();
const UserType = new GraphQLObjectType({
name: 'User',
fields: () => ({
id: { type: GraphQLInt },
fullName: {
type: GraphQLString,
sqlExpr: (table, args) => `CONCAT(${table}.first_name, ' ', ${table}.last_name)`
},
email: { type: GraphQLString }
})
});
const QueryRoot = new GraphQLObjectType({
name: 'Query',
fields: {
user: {
type: UserType,
args: { id: { type: GraphQLInt } },
sqlTable: 'users',
uniqueKey: 'id',
resolve: (parent, args, context, resolveInfo) => {
return joinMonster(resolveInfo, context, sql => {
return context.db.query(sql);
}, { dialect: 'mysql' });
}
}
}
});
const schema = new GraphQLSchema({ query: QueryRoot });
app.use('/graphql', graphqlHTTP({ schema }));
app.listen(4000, () => console.log('Server running on port 4000'));
Errors
Common errors & fixes
joinMonster is not a function
Default import used incorrectly (e.g., import { joinMonster } instead of import joinMonster).
fixUse default import: import joinMonster from 'join-monster'
Cannot find module 'join-monster'
Package not installed or incorrect import path.
fixRun npm install join-monster and ensure import path is correct.
TypeError: resolveInfo is not a plain object
joinMonster requires the fourth argument of resolve function (resolveInfo) to be a valid GraphQLResolveInfo object.
fixPass resolveInfo directly from the resolve function's arguments.
sqlExpr function not working as expected
sqlExpr is defined on the field but the table alias is not properly referenced.
fixUse the 'table' parameter provided to sqlExpr, e.g., `table.column_name`.
Audit
Dependencies
graphqlrequiredpeer dependency required for schema introspection and query execution