@cran/lib.gql.jm
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

@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
}

Package Sidebar

Install

npm i @cran/lib.gql.jm

Weekly Downloads

1

Version

0.0.1

License

SEE LICENSE IN license.md

Unpacked Size

178 kB

Total Files

116

Last publish

Collaborators

  • common-cranberry