You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

graphile-build-pg

Package Overview
Dependencies
Maintainers
1
Versions
207
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphile-build-pg

Build a GraphQL schema by reflection over a PostgreSQL schema. Easy to customize since it's built with plugins on graphile-build


Version published
Weekly downloads
26K
decreased by-1.22%
Maintainers
1
Created
Weekly downloads
 

Changelog

Source

4.0.0-beta.1 (2018-03-10)

Bug Fixes

  • sql: still introspect when standard_conforming_strings is off (#193) (4d1500b)

Readme

Source

graphile-build-pg

graphile-build-pg is a collection of plugins for graphile-build that allow you to extend your GraphQL schema with high-performance types and fields based on resources found in your PostgreSQL database schema.

The plugins here-in do not exhibit the N+1 query problem common in many database-based GraphQL APIs thanks to graphile-build's advanced look-ahead features, they're more efficient, even, than DataLoader-based solutions.

An example of an application built on graphile-build-pg is PostGraphile v4+ which allows you to run just one command to instantly get a fully working and secure GraphQL API up and running based on your PostgreSQL database schema.

It is recommended that you use PostGraphile directly unless you really want to get low level access to this library.

If you prefer to use the plugins yourself it's advised that you use the defaultPlugins export from graphile-build-pg and then create a new array based on that into which you may insert or remove specific plugins. This is because it is ordered in a way to ensure the plugins work correctly (and we may still split up or restructure the plugins within it).

defaultPlugins

An array of graphql-build plugins in the correct order to generate a well-thought-out GraphQL object tree based on your PostgreSQL schema. This is the array that postgraphile-core uses.

inflections

This is a list of inflection engines, we currently have the following:

  • defaultInflection - a sensible default
  • postGraphileInflection - as above, but enums get converted to CONSTANT_CASE
  • postGraphileClassicIdsInflection - as above, but id attributes get renamed to rowId to prevent conflicts with id from the Relay Global Unique Object Specification.

Manual usage

import { defaultPlugins, getBuilder } from "graphile-build";
import {
  defaultPlugins as pgDefaultPlugins,
  inflections: {
    defaultInflection,
  },
} from "graphile-build-pg";

async function getSchema(pgConfig = process.env.DATABASE_URL, pgSchemas = ['public'], additionalPlugins = []) {
  return getBuilder(
    [
      ...defaultPlugins,
      ...pgDefaultPlugins,
      ...additionalPlugins
    ],
    {
      pgConfig,
      pgSchemas,
      pgExtendedTypes: true,
      pgInflection: defaultInflection,
    }
  );
}

Keywords

FAQs

Package last updated on 10 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc