Members

joinMonsterPromise.<Object>

Takes the GraphQL resolveInfo and returns a hydrated Object with the data.

getSQLPromise.<string>

Takes the GraphQL resolveInfo and returns only the SQL query.

getNodePromise.<Object>

A helper for resolving the Node type in Relay.

Typedefs

dbCallArray | Promise.<Array>

User-defined function that sends a raw SQL query to the databse.

sqlExprString

Function for generating a SQL expression.

whereString

Function for generating a WHERE condition.

sqlJoinString

Function for generating a JOIN condition.

joinMonster ⇒ Promise.<Object>

Takes the GraphQL resolveInfo and returns a hydrated Object with the data.

Returns: Promise.<Object> - The correctly nested data from the database.

Param Type Description
resolveInfo Object Contains the parsed GraphQL query, schema definition, and more. Obtained from the fourth argument to the resolver.
context Object An arbitrary object that gets passed to the where function. Useful for contextual infomation that influeces the WHERE condition, e.g. session, logged in user, localization.
dbCall dbCall A function that is passed the compiled SQL that calls the database and returns (a promise of) the data.
[options] Object
options.minify Boolean Generate minimum-length column names in the results table.
options.dialect String The dialect of SQL your Database uses. Currently 'pg', 'mysql', and 'standard' are supported.

getSQL ⇒ Promise.<string>

Takes the GraphQL resolveInfo and returns only the SQL query.

Returns: Promise.<string> - The SQL query generated

Param Type Description
resolveInfo Object Contains the parsed GraphQL query, schema definition, and more. Obtained from the fourth argument to the resolver.
context Object An arbitrary object that gets passed to the where function. Useful for contextual infomation that influeces the WHERE condition, e.g. session, logged in user, localization.
[options] Object Same as joinMonster function's options.

getNode ⇒ Promise.<Object>

A helper for resolving the Node type in Relay.

Returns: Promise.<Object> - The correctly nested data from the database. The GraphQL Type is added to the "__type__" property, which is helpful for the resolveType function in the nodeDefinitions of graphql-relay-js.

Param Type Description
typeName String The Name of the GraphQLObjectType
resolveInfo Object Contains the parsed GraphQL query, schema definition, and more. Obtained from the fourth argument to the resolver.
context Object An arbitrary object that gets passed to the where function. Useful for contextual infomation that influeces the WHERE condition, e.g. session, logged in user, localization.
condition where | Number | String | Array A value to determine the where function for searching the node. If it's a function, that function will be used as the where function. Otherwise, it is assumed to be the value(s) of the primaryKey. An array of values is needed for composite primary keys.
dbCall function A function that is passed the compiled SQL that calls the database and returns (a promise of) the data.
[options] Object Same as joinMonster function's options.

dbCall ⇒ Array | Promise.<Array>

User-defined function that sends a raw SQL query to the databse.

Returns: Array | Promise.<Array> - The raw data as a flat array of objects. Each object must represent a row from the result set.

Param Type Description
sql String The SQL generated by joinMonster for the batch fetching. Use it to get the data from your database.
[done] function An error-first "done" callback. Only define this parameter if you don't want to return a Promise.

sqlExpr ⇒ String

Function for generating a SQL expression.

Returns: String - The expression interpolated into the query to compute the column.

Param Type Description
tableAlias String The alias generated for this table. Already double-quoted.
args Object The GraphQL arguments for this field.
context Object An Object with arbitrary contextual information.

where ⇒ String

Function for generating a WHERE condition.

Returns: String - The condition for the WHERE clause.

Param Type Description
tableAlias String The alias generated for this table. Already double-quoted.
args Object The GraphQL arguments for this field.
context Object An Object with arbitrary contextual information.
parentAliases Array.<String> List of aliases of the antecedent tables, starting with the parent field.

sqlJoin ⇒ String

Function for generating a JOIN condition.

Returns: String - The condition for the LEFT JOIN.

Param Type Description
parentTable String The alias generated for the parent's table. Already double-quoted.
childTable String The alias for the child's table. Already double-quoted.
args Object The GraphQL arguments for this field.
context Object An Object with arbitrary contextual information.