@cran/lib.gql.jm
v0.0.1
Published
GraphQL JoinMonster Integration
Downloads
7
Maintainers
Readme
@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
|||Column Expression
|where|text
|||Where statement
|order|text
|||Order records by
|limit|text
|||Enforced record limit
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
}