graphile-build-pg
Advanced tools
Comparing version 4.0.0-alpha.1 to 4.0.0-alpha.2
@@ -91,3 +91,3 @@ "use strict"; | ||
return { | ||
description: "An edge for the type. May be used by Relay 1.", | ||
description: `An edge for our \`${tableTypeName}\`. May be used by Relay 1.`, | ||
type: TableEdgeType, | ||
@@ -94,0 +94,0 @@ args: { |
@@ -281,2 +281,3 @@ "use strict"; | ||
memo[inflection.column(key.name, key.class.name, key.class.namespace.name)] = { | ||
description: key.description, | ||
type: new GraphQLNonNull(pgGetGqlInputTypeByTypeId(key.typeId)) | ||
@@ -283,0 +284,0 @@ }; |
@@ -15,3 +15,3 @@ "use strict"; | ||
exports.default = function PgTablesPlugin(builder, { pgInflection: inflection }) { | ||
exports.default = function PgTablesPlugin(builder, { pgInflection: inflection, pgForbidSetofFunctionsToReturnNull = false }) { | ||
builder.hook("init", (_, { | ||
@@ -29,2 +29,3 @@ newWithHooks, | ||
}) => { | ||
const nullableIf = (condition, Type) => condition ? Type : new GraphQLNonNull(Type); | ||
const Cursor = getTypeByName("Cursor"); | ||
@@ -82,3 +83,3 @@ introspectionResultsByKind.procedure.filter(proc => proc.returnsSet).filter(proc => !!proc.namespace).forEach(proc => { | ||
description: `A list of \`${NodeType.name}\` objects.`, | ||
type: new GraphQLNonNull(new GraphQLList(NodeType)), | ||
type: new GraphQLNonNull(new GraphQLList(nullableIf(!pgForbidSetofFunctionsToReturnNull, NodeType))), | ||
resolve(data) { | ||
@@ -85,0 +86,0 @@ return data.data.map(entry => entry.value); |
@@ -11,2 +11,6 @@ "use strict"; | ||
var _keys = require("babel-runtime/core-js/object/keys"); | ||
var _keys2 = _interopRequireDefault(_keys); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -16,3 +20,11 @@ | ||
exports.default = function PgTablesPlugin(builder, { pgInflection: inflection }) { | ||
exports.default = function PgTablesPlugin(builder, { pgInflection: inflection, pgForbidSetofFunctionsToReturnNull = false }) { | ||
const handleNullRow = pgForbidSetofFunctionsToReturnNull ? row => row : row => { | ||
if ((0, _keys2.default)(row).filter(str => !str.startsWith("__")).some(key => row[key] !== null)) { | ||
return row; | ||
} else { | ||
return null; | ||
} | ||
}; | ||
builder.hook("init", (_, build) => { | ||
@@ -41,2 +53,3 @@ const { | ||
} = build; | ||
const nullableIf = (condition, Type) => condition ? Type : new GraphQLNonNull(Type); | ||
const Cursor = getTypeByName("Cursor"); | ||
@@ -187,5 +200,5 @@ introspectionResultsByKind.class.forEach(table => { | ||
description: `The \`${tableTypeName}\` at the end of the edge.`, | ||
type: new GraphQLNonNull(TableType), | ||
type: nullableIf(!pgForbidSetofFunctionsToReturnNull, TableType), | ||
resolve(data) { | ||
return data; | ||
return handleNullRow(data); | ||
} | ||
@@ -215,3 +228,3 @@ } | ||
resolve(data) { | ||
return data.data; | ||
return data.data.map(handleNullRow); | ||
} | ||
@@ -218,0 +231,0 @@ }, |
{ | ||
"name": "graphile-build-pg", | ||
"version": "4.0.0-alpha.1", | ||
"version": "4.0.0-alpha.2", | ||
"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": "node8plus/index.js", |
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
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
894860
4803