Members
- joinMonster ⇒
Promise.<Object> Takes the GraphQL resolveInfo and returns a hydrated Object with the data.
- getNode ⇒
Promise.<Object> A helper for resolving the Node type in Relay.
Typedefs
- dbCall ⇒
Promise.<Array> User-defined function that sends a raw SQL query to the databse.
- sqlExpr ⇒
String|Promise.<String> Function for generating a SQL expression.
- where ⇒
String|Promise.<String> Function for generating a
WHEREcondition.- sqlJoin ⇒
String Function for generating a
JOINcondition.- thunk :
function Rather than a constant value, its a function to dynamically return the value.
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.aliasPrefix | String |
String to prefix to column and table names, useful to avoid conflicts in subquery expressions. |
| options.dialect | String |
The dialect of SQL your Database uses. Currently 'pg', 'oracle', 'mariadb', 'mysql', and 'sqlite3' are supported. |
| options.dialectModule | Object |
An alternative to options.dialect. You can provide a custom implementation of one of the supported dialects. |
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 ⇒ Promise.<Array>
User-defined function that sends a raw SQL query to the databse.
Returns: 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 | Promise.<String>
Function for generating a SQL expression.
Returns: String | Promise.<String> - The RAW expression interpolated into the query to compute the column. Unsafe user input must be scrubbed.
| 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. |
| sqlASTNode | Object |
Join Monster object that abstractly represents this field. Also includes a reference to its parent node. This is useful, for example, if you need to access the parent field's table alias or GraphQL arguments. |
where ⇒ String | Promise.<String>
Function for generating a WHERE condition.
Returns: String | Promise.<String> - The RAW condition for the WHERE clause. Omitted if falsy value returned. Unsafe user input must be scrubbed.
| 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. |
| sqlASTNode | Object |
Join Monster object that abstractly represents this field. Also includes a reference to its parent node. This is useful, for example, if you need to access the parent field's table alias or GraphQL arguments. |
sqlJoin ⇒ String
Function for generating a JOIN condition.
Returns: String - The RAW condition for the LEFT JOIN. Unsafe user input must be scrubbed.
| 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. |
| sqlASTNode | Object |
Join Monster object that abstractly represents this field. Also includes a reference to its parent node. This is useful, for example, if you need to access the parent field's table alias or GraphQL arguments. |
thunk : function
Rather than a constant value, it's a function to dynamically return the value.
| Param | Type | Description |
|---|---|---|
| args | Object |
The GraphQL arguments for this field. |
| context | Object |
An Object with arbitrary contextual information. |