Socket
Socket
Sign inDemoInstall

graphile-build-pg

Package Overview
Dependencies
Maintainers
1
Versions
208
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphile-build-pg - npm Package Compare versions

Comparing version 0.1.0-alpha.20 to 0.1.0-alpha.21

5

node7minus/plugins/PgTablesPlugin.js

@@ -82,2 +82,3 @@ "use strict";

var tableTypeName = inflection.tableType(table.name, schema && schema.name);
var shouldHaveNodeId = nodeIdFieldName && table.isSelectable && primaryKeys && primaryKeys.length ? true : false;
var TableType = newWithHooks(GraphQLObjectType, {

@@ -87,3 +88,3 @@ description: table.description || tablePgType.description,

interfaces: function interfaces() {
if (nodeIdFieldName && table.isSelectable) {
if (shouldHaveNodeId) {
return [getTypeByName("Node")];

@@ -99,3 +100,3 @@ } else {

var fields = {};
if (nodeIdFieldName && table.isSelectable) {
if (shouldHaveNodeId) {
// Enable nodeId interface

@@ -102,0 +103,0 @@ addDataGeneratorForField(nodeIdFieldName, function () {

@@ -63,2 +63,3 @@ "use strict";

const tableTypeName = inflection.tableType(table.name, schema && schema.name);
const shouldHaveNodeId = nodeIdFieldName && table.isSelectable && primaryKeys && primaryKeys.length ? true : false;
const TableType = newWithHooks(GraphQLObjectType, {

@@ -68,3 +69,3 @@ description: table.description || tablePgType.description,

interfaces: () => {
if (nodeIdFieldName && table.isSelectable) {
if (shouldHaveNodeId) {
return [getTypeByName("Node")];

@@ -77,3 +78,3 @@ } else {

const fields = {};
if (nodeIdFieldName && table.isSelectable) {
if (shouldHaveNodeId) {
// Enable nodeId interface

@@ -80,0 +81,0 @@ addDataGeneratorForField(nodeIdFieldName, () => {

2

package.json
{
"name": "graphile-build-pg",
"version": "0.1.0-alpha.20",
"version": "0.1.0-alpha.21",
"description": "Build a GraphQL schema by reflection over a PostgreSQL schema. Easy to customize since it's built with plugins on graphile-build",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -18,3 +18,52 @@ graphile-build-pg

**For in-depth documentation about `graphile-build-pg`, please see [the
graphile documentation website](https://www.graphile.org/).**
**It is recommended that you use PostGraphQL 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
- `postGraphQLInflection` - as above, but enums get converted to `CONSTANT_CASE`
- `postGraphQLClassicIdsInflection` - as above, but `id` attributes get renamed to `rowId` to prevent conflicts with `id` from the Relay Global Unique Object Specification.
### Manual usage
```js
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,
}
);
}
```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc