graphile-gen-sql

0.3.3 • Public • Published

graphile-gen-sql

Generate mutations/queries for your PostGraphile projects

  • assumes using simple inflection
npm install graphile-gen-sql

introspecting via Postgres

import {
  pg as gen
} from 'graphile-gen-sql';
import { print } from 'graphql/language';

const { ast } = gen.createOne(tableDefn);
console.log(print(ast));

introspecting via GraphQL

import {
  gql as gen
} from 'graphile-gen-sql';
import { print } from 'graphql/language';

const { ast } = pgGen.generate(resultOfIntrospectionQuery);
console.log(print(ast));

output

which will output:

mutation createProductMutation($id: UUID, $ownerId: UUID, $name: String!, $rhinoFoot: String, $hiddenFoot: String, $lizardFeet: String) {
  createProduct(input: {product: {id: $id, ownerId: $ownerId, name: $name, rhinoFoot: $rhinoFoot, hiddenFoot: $hiddenFoot, lizardFeet: $lizardFeet}}) {
    product {
      id
      ownerId
      name
      rhinoFoot
      hiddenFoot
      lizardFeet
    }
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i graphile-gen-sql

Weekly Downloads

6

Version

0.3.3

License

SEE LICENSE IN LICENSE

Unpacked Size

77.9 kB

Total Files

14

Last publish

Collaborators

  • pyramation