@cran/lib.gql.jm
GraphQL JoinMonster Integration
Setup
import { Plugin, withCoreFeatures } from "@cran/lib.gql.core";
import { withJm } from "@cran/lib.gql.jm";
export const schema = Plugin.apply(Plugin.compose([
// ORDER MATTERS
{ typeDefs: fs.readFileSync(`${__dirname}/schema.gql`, "utf-8"), },
...withCoreFeatures(),
...withJm(),
]));
Inflection
Want to rename things?
...withJm({
inflection: {
sqlTable: "MakeTable"
}
});
type Table
@MakeTable
{ }
Example
For a more complete example see example in poc
, this follows the
join-monster documentation
for data and schema structure.
Directives
Resolver
Note: This one is critical for functionality
sqlResolver on COMPOSITE_FIELD
type Query {
accounts: [Account!]
@sqlResolver
}
Table
sqlTable on COMPOSITE_TYPE
Parameter | Type | Default | Description |
---|---|---|---|
name | text |
type.name |
Table Name |
key | [text!] |
["id"] |
Primary Key |
fetch | [text!] |
Always get these fields |
type Type
@sqlTable(name: "table_name")
{ }
Column
on COMPOSITE_FIELD
Parameter | Type | Default | Description |
---|---|---|---|
name | text |
type.name |
Column Name |
deps | [text!] |
Dependencies | |
expr | text |
||
where | text |
||
order | text |
||
limit | text |
type Type
@sqlTable(name: "table_name")
{
id
@sqlColumn(name: "table_name_id")
}
Pagination
sqlPaginate on COMPOSITE_FIELD
Parameter | Type | Default | Description |
---|---|---|---|
limit | text |
infinity | Maximum page size |
size | [text!] |
Default page size | |
sort | text |
Keys to sort by |
type Query {
types: [Type!]
@sqlPaginate(limit: 100, size: 20)
@sqlResolver
}