graphile-build-pg
Advanced tools
Comparing version 4.0.0-beta.7.2 to 4.0.0-beta.8
@@ -11,3 +11,3 @@ "use strict"; | ||
function cursorify(val) { | ||
return val && val.__cursor ? base64(JSON.stringify(val.__cursor)) : val; | ||
return val && val.__cursor ? base64(JSON.stringify(val.__cursor)) : null; | ||
} | ||
@@ -14,0 +14,0 @@ |
@@ -44,3 +44,4 @@ "use strict"; | ||
parseResolveInfo, | ||
getAliasFromResolveInfo, | ||
getSafeAliasFromResolveInfo, | ||
getSafeAliasFromAlias, | ||
gql2pg, | ||
@@ -248,3 +249,3 @@ pg2gql, | ||
return sql.fragment`(${query})`; | ||
}, parsedResolveInfoFragment.alias); | ||
}, getSafeAliasFromAlias(parsedResolveInfoFragment.alias)); | ||
} | ||
@@ -324,4 +325,4 @@ }; | ||
resolve: computed ? (data, _args, _context, resolveInfo) => { | ||
const alias = getAliasFromResolveInfo(resolveInfo); | ||
const value = data[alias]; | ||
const safeAlias = getSafeAliasFromResolveInfo(resolveInfo); | ||
const value = data[safeAlias]; | ||
if (returnFirstValueAsValue) { | ||
@@ -328,0 +329,0 @@ if (proc.returnsSet && !forceList) { |
@@ -8,3 +8,5 @@ "use strict"; | ||
exports.default = function PageInfoStartEndCursor(builder) { | ||
builder.hook("GraphQLObjectType:fields", (fields, { extend, getTypeByName }, { Self, fieldWithHooks }) => { | ||
builder.hook("GraphQLObjectType:fields", (fields, build, context) => { | ||
const { extend, getTypeByName } = build; | ||
const { Self, fieldWithHooks } = context; | ||
if (Self.name !== "PageInfo") { | ||
@@ -11,0 +13,0 @@ return fields; |
@@ -30,12 +30,14 @@ "use strict"; | ||
const hasSimpleCollections = pgSimpleCollections === "only" || pgSimpleCollections === "both"; | ||
builder.hook("GraphQLObjectType:fields", (fields, { | ||
parseResolveInfo, | ||
extend, | ||
getTypeByName, | ||
pgGetGqlTypeByTypeId, | ||
pgSql: sql, | ||
pgIntrospectionResultsByKind: introspectionResultsByKind, | ||
inflection, | ||
graphql: { GraphQLList, GraphQLNonNull } | ||
}, { fieldWithHooks, scope: { isRootQuery } }) => { | ||
builder.hook("GraphQLObjectType:fields", (fields, build, context) => { | ||
const { | ||
parseResolveInfo, | ||
extend, | ||
getTypeByName, | ||
pgGetGqlTypeByTypeId, | ||
pgSql: sql, | ||
pgIntrospectionResultsByKind: introspectionResultsByKind, | ||
inflection, | ||
graphql: { GraphQLList, GraphQLNonNull } | ||
} = build; | ||
const { fieldWithHooks, scope: { isRootQuery } } = context; | ||
if (!isRootQuery) { | ||
@@ -42,0 +44,0 @@ return fields; |
@@ -38,16 +38,19 @@ "use strict"; | ||
}[pgLegacyRelations] || OMIT; | ||
builder.hook("GraphQLObjectType:fields", (fields, { | ||
extend, | ||
getTypeByName, | ||
pgGetGqlTypeByTypeId, | ||
pgIntrospectionResultsByKind: introspectionResultsByKind, | ||
pgSql: sql, | ||
getAliasFromResolveInfo, | ||
graphql: { GraphQLNonNull, GraphQLList }, | ||
inflection | ||
}, { | ||
scope: { isPgRowType, pgIntrospection: foreignTable }, | ||
fieldWithHooks, | ||
Self | ||
}) => { | ||
builder.hook("GraphQLObjectType:fields", (fields, build, context) => { | ||
const { | ||
extend, | ||
getTypeByName, | ||
pgGetGqlTypeByTypeId, | ||
pgIntrospectionResultsByKind: introspectionResultsByKind, | ||
pgSql: sql, | ||
getSafeAliasFromResolveInfo, | ||
getSafeAliasFromAlias, | ||
graphql: { GraphQLNonNull, GraphQLList }, | ||
inflection | ||
} = build; | ||
const { | ||
scope: { isPgRowType, pgIntrospection: foreignTable }, | ||
fieldWithHooks, | ||
Self | ||
} = context; | ||
if (!isPgRowType || !foreignTable || foreignTable.kind !== "class") { | ||
@@ -129,3 +132,3 @@ return fields; | ||
return sql.fragment`(${query})`; | ||
}, parsedResolveInfoFragment.alias); | ||
}, getSafeAliasFromAlias(parsedResolveInfoFragment.alias)); | ||
} | ||
@@ -139,4 +142,4 @@ }; | ||
resolve: (data, _args, _context, resolveInfo) => { | ||
const alias = getAliasFromResolveInfo(resolveInfo); | ||
return data[alias]; | ||
const safeAlias = getSafeAliasFromResolveInfo(resolveInfo); | ||
return data[safeAlias]; | ||
} | ||
@@ -156,6 +159,3 @@ }; | ||
memo[manyRelationFieldName] = fieldWithHooks(manyRelationFieldName, ({ | ||
getDataFromParsedResolveInfoFragment, | ||
addDataGenerator | ||
}) => { | ||
memo[manyRelationFieldName] = fieldWithHooks(manyRelationFieldName, ({ getDataFromParsedResolveInfoFragment, addDataGenerator }) => { | ||
addDataGenerator(parsedResolveInfoFragment => { | ||
@@ -191,3 +191,3 @@ return { | ||
return sql.fragment`(${query})`; | ||
}, parsedResolveInfoFragment.alias); | ||
}, getSafeAliasFromAlias(parsedResolveInfoFragment.alias)); | ||
} | ||
@@ -203,7 +203,7 @@ }; | ||
resolve: (data, _args, _context, resolveInfo) => { | ||
const alias = getAliasFromResolveInfo(resolveInfo); | ||
const safeAlias = getSafeAliasFromResolveInfo(resolveInfo); | ||
if (isConnection) { | ||
return (0, _addStartEndCursor2.default)(data[alias]); | ||
return (0, _addStartEndCursor2.default)(data[safeAlias]); | ||
} else { | ||
return data[alias]; | ||
return data[safeAlias]; | ||
} | ||
@@ -210,0 +210,0 @@ }, |
@@ -28,3 +28,2 @@ "use strict"; | ||
graphql: { GraphQLString, GraphQLNonNull }, | ||
getAliasFromResolveInfo, | ||
pgTweakFragmentForType, | ||
@@ -64,3 +63,2 @@ pgColumnFilter, | ||
addDataGenerator(parsedResolveInfoFragment => { | ||
const { alias } = parsedResolveInfoFragment; | ||
return { | ||
@@ -94,3 +92,3 @@ pgQuery: queryBuilder => { | ||
queryBuilder.select(getSelectValueForFieldAndType(sql.fragment`(${queryBuilder.getTableAlias()}.${sql.identifier(attr.name)})`, // The brackets are necessary to stop the parser getting confused, ref: https://www.postgresql.org/docs/9.6/static/rowtypes.html#ROWTYPES-ACCESSING | ||
attr.type), alias); | ||
attr.type), fieldName); | ||
} | ||
@@ -102,5 +100,4 @@ }; | ||
type: nullableIf(GraphQLNonNull, !attr.isNotNull && !attr.type.domainIsNotNull, ReturnType), | ||
resolve: (data, _args, _context, resolveInfo) => { | ||
const alias = getAliasFromResolveInfo(resolveInfo); | ||
return pg2gql(data[alias], attr.type); | ||
resolve: (data, _args, _context, _resolveInfo) => { | ||
return pg2gql(data[fieldName], attr.type); | ||
} | ||
@@ -107,0 +104,0 @@ }; |
@@ -20,12 +20,13 @@ "use strict"; | ||
const hasSimpleCollections = pgSimpleCollections === "only" || pgSimpleCollections === "both"; | ||
builder.hook("GraphQLObjectType:fields", (fields, build, { | ||
scope: { | ||
isPgRowType, | ||
isPgCompoundType, | ||
isInputType, | ||
pgIntrospection: table | ||
}, | ||
fieldWithHooks, | ||
Self | ||
}) => { | ||
builder.hook("GraphQLObjectType:fields", (fields, build, context) => { | ||
const { | ||
scope: { | ||
isPgRowType, | ||
isPgCompoundType, | ||
isInputType, | ||
pgIntrospection: table | ||
}, | ||
fieldWithHooks, | ||
Self | ||
} = context; | ||
if (isInputType || !(isPgRowType || isPgCompoundType) || !table || table.kind !== "class" || !table.namespace) { | ||
@@ -45,15 +46,15 @@ return fields; | ||
/* | ||
proc = | ||
{ kind: 'procedure', | ||
name: 'integration_webhook_secret', | ||
description: null, | ||
namespaceId: '6484381', | ||
isStrict: false, | ||
returnsSet: false, | ||
isStable: true, | ||
returnTypeId: '2950', | ||
argTypeIds: [ '6484569' ], | ||
argNames: [ 'integration' ], | ||
argDefaultsNum: 0 } | ||
*/ | ||
proc = | ||
{ kind: 'procedure', | ||
name: 'integration_webhook_secret', | ||
description: null, | ||
namespaceId: '6484381', | ||
isStrict: false, | ||
returnsSet: false, | ||
isStable: true, | ||
returnTypeId: '2950', | ||
argTypeIds: [ '6484569' ], | ||
argNames: [ 'integration' ], | ||
argDefaultsNum: 0 } | ||
*/ | ||
const argTypes = proc.argTypeIds.map(typeId => introspectionResultsByKind.typeById[typeId]); | ||
@@ -60,0 +61,0 @@ if (argTypes.slice(1).some(type => type.type === "c" && type.class && type.class.isSelectable)) { |
@@ -11,12 +11,14 @@ "use strict"; | ||
exports.default = function PgConnectionArgs(builder) { | ||
builder.hook("GraphQLObjectType:fields:field:args", (args, { extend, getTypeByName, graphql: { GraphQLInt } }, { | ||
scope: { | ||
isPgFieldConnection, | ||
isPgFieldSimpleCollection, | ||
pgFieldIntrospection: source | ||
}, | ||
addArgDataGenerator, | ||
field, | ||
Self | ||
}) => { | ||
builder.hook("GraphQLObjectType:fields:field:args", (args, build, context) => { | ||
const { extend, getTypeByName, graphql: { GraphQLInt } } = build; | ||
const { | ||
scope: { | ||
isPgFieldConnection, | ||
isPgFieldSimpleCollection, | ||
pgFieldIntrospection: source | ||
}, | ||
addArgDataGenerator, | ||
field, | ||
Self | ||
} = context; | ||
if (!(isPgFieldConnection || isPgFieldSimpleCollection) || !source || source.kind !== "class" && source.kind !== "procedure") { | ||
@@ -23,0 +25,0 @@ return args; |
@@ -18,8 +18,9 @@ "use strict"; | ||
exports.default = function PgConnectionArgOrderBy(builder) { | ||
builder.hook("init", (_, { | ||
newWithHooks, | ||
pgIntrospectionResultsByKind: introspectionResultsByKind, | ||
graphql: { GraphQLEnumType }, | ||
inflection | ||
}) => { | ||
builder.hook("init", (_, build) => { | ||
const { | ||
newWithHooks, | ||
pgIntrospectionResultsByKind: introspectionResultsByKind, | ||
graphql: { GraphQLEnumType }, | ||
inflection | ||
} = build; | ||
introspectionResultsByKind.class.filter(table => table.isSelectable && !(0, _omit2.default)(table, "order")).filter(table => !!table.namespace).forEach(table => { | ||
@@ -46,19 +47,21 @@ const tableTypeName = inflection.tableType(table); | ||
}); | ||
builder.hook("GraphQLObjectType:fields:field:args", (args, { | ||
extend, | ||
getTypeByName, | ||
pgGetGqlTypeByTypeId, | ||
pgSql: sql, | ||
graphql: { GraphQLList, GraphQLNonNull }, | ||
inflection | ||
}, { | ||
scope: { | ||
isPgFieldConnection, | ||
isPgFieldSimpleCollection, | ||
pgFieldIntrospection: table | ||
}, | ||
addArgDataGenerator, | ||
Self, | ||
field | ||
}) => { | ||
builder.hook("GraphQLObjectType:fields:field:args", (args, build, context) => { | ||
const { | ||
extend, | ||
getTypeByName, | ||
pgGetGqlTypeByTypeId, | ||
pgSql: sql, | ||
graphql: { GraphQLList, GraphQLNonNull }, | ||
inflection | ||
} = build; | ||
const { | ||
scope: { | ||
isPgFieldConnection, | ||
isPgFieldSimpleCollection, | ||
pgFieldIntrospection: table | ||
}, | ||
addArgDataGenerator, | ||
Self, | ||
field | ||
} = context; | ||
const shouldAddOrderBy = isPgFieldConnection || isPgFieldSimpleCollection; | ||
@@ -65,0 +68,0 @@ if (!shouldAddOrderBy || !table || table.kind !== "class" || !table.namespace || !table.isSelectable || (0, _omit2.default)(table, "order")) { |
@@ -8,7 +8,9 @@ "use strict"; | ||
exports.default = function PgConnectionArgOrderByDefaultValue(builder) { | ||
builder.hook("GraphQLObjectType:fields:field:args", (args, { extend, getTypeByName, pgGetGqlTypeByTypeId, inflection }, { | ||
scope: { isPgFieldConnection, pgFieldIntrospection: table }, | ||
Self, | ||
field | ||
}) => { | ||
builder.hook("GraphQLObjectType:fields:field:args", (args, build, context) => { | ||
const { extend, getTypeByName, pgGetGqlTypeByTypeId, inflection } = build; | ||
const { | ||
scope: { isPgFieldConnection, pgFieldIntrospection: table }, | ||
Self, | ||
field | ||
} = context; | ||
if (!isPgFieldConnection || !table || table.kind !== "class" || !table.namespace || !table.isSelectable || !args.orderBy) { | ||
@@ -15,0 +17,0 @@ return args; |
@@ -8,7 +8,9 @@ "use strict"; | ||
exports.default = function PgConnectionTotalCount(builder) { | ||
builder.hook("GraphQLObjectType:fields", (fields, { extend, inflection, graphql: { GraphQLInt } }, { | ||
scope: { isPgRowConnectionType, pgIntrospection: table }, | ||
fieldWithHooks, | ||
Self | ||
}) => { | ||
builder.hook("GraphQLObjectType:fields", (fields, build, context) => { | ||
const { extend, inflection, graphql: { GraphQLInt } } = build; | ||
const { | ||
scope: { isPgRowConnectionType, pgIntrospection: table }, | ||
fieldWithHooks, | ||
Self | ||
} = context; | ||
if (!isPgRowConnectionType || !table || table.kind !== "class" || !table.namespace) { | ||
@@ -15,0 +17,0 @@ return fields; |
@@ -24,19 +24,22 @@ "use strict"; | ||
exports.default = function PgForwardRelationPlugin(builder) { | ||
builder.hook("GraphQLObjectType:fields", (fields, { | ||
extend, | ||
getAliasFromResolveInfo, | ||
pgGetGqlTypeByTypeId, | ||
pgIntrospectionResultsByKind: introspectionResultsByKind, | ||
pgSql: sql, | ||
inflection | ||
}, { | ||
scope: { | ||
isPgRowType, | ||
isMutationPayload, | ||
pgIntrospection, | ||
pgIntrospectionTable | ||
}, | ||
fieldWithHooks, | ||
Self | ||
}) => { | ||
builder.hook("GraphQLObjectType:fields", (fields, build, context) => { | ||
const { | ||
extend, | ||
getSafeAliasFromResolveInfo, | ||
getSafeAliasFromAlias, | ||
pgGetGqlTypeByTypeId, | ||
pgIntrospectionResultsByKind: introspectionResultsByKind, | ||
pgSql: sql, | ||
inflection | ||
} = build; | ||
const { | ||
scope: { | ||
isPgRowType, | ||
isMutationPayload, | ||
pgIntrospection, | ||
pgIntrospectionTable | ||
}, | ||
fieldWithHooks, | ||
Self | ||
} = context; | ||
const table = pgIntrospectionTable || pgIntrospection; | ||
@@ -104,3 +107,3 @@ if (!(isPgRowType || isMutationPayload) || !table || table.kind !== "class" || !table.namespace) { | ||
return sql.fragment`(${query})`; | ||
}, parsedResolveInfoFragment.alias); | ||
}, getSafeAliasFromAlias(parsedResolveInfoFragment.alias)); | ||
} | ||
@@ -114,4 +117,4 @@ }; | ||
const data = isMutationPayload ? rawData.data : rawData; | ||
const alias = getAliasFromResolveInfo(resolveInfo); | ||
return data[alias]; | ||
const safeAlias = getSafeAliasFromResolveInfo(resolveInfo); | ||
return data[safeAlias]; | ||
} | ||
@@ -118,0 +121,0 @@ }; |
@@ -16,12 +16,13 @@ "use strict"; | ||
exports.default = function PgJWTPlugin(builder, { pgJwtTypeIdentifier, pgJwtSecret }) { | ||
builder.hook("init", (_, { | ||
newWithHooks, | ||
pgSql: sql, | ||
pgIntrospectionResultsByKind: introspectionResultsByKind, | ||
pgRegisterGqlTypeByTypeId, | ||
pg2GqlMapper, | ||
pgTweaksByTypeId, | ||
graphql: { GraphQLScalarType }, | ||
inflection | ||
}) => { | ||
builder.hook("init", (_, build) => { | ||
const { | ||
newWithHooks, | ||
pgSql: sql, | ||
pgIntrospectionResultsByKind: introspectionResultsByKind, | ||
pgRegisterGqlTypeByTypeId, | ||
pg2GqlMapper, | ||
pgTweaksByTypeId, | ||
graphql: { GraphQLScalarType }, | ||
inflection | ||
} = build; | ||
if (!pgJwtTypeIdentifier) { | ||
@@ -28,0 +29,0 @@ return _; |
@@ -31,3 +31,3 @@ "use strict"; | ||
} | ||
builder.hook("GraphQLObjectType:fields", (fields, build, { scope: { isRootMutation }, fieldWithHooks }) => { | ||
builder.hook("GraphQLObjectType:fields", (fields, build, context) => { | ||
const { | ||
@@ -51,2 +51,3 @@ extend, | ||
} = build; | ||
const { scope: { isRootMutation }, fieldWithHooks } = context; | ||
if (!isRootMutation) { | ||
@@ -53,0 +54,0 @@ return fields; |
@@ -18,16 +18,18 @@ "use strict"; | ||
exports.default = function PgMutationPayloadEdgePlugin(builder) { | ||
builder.hook("GraphQLObjectType:fields", (fields, { | ||
extend, | ||
getTypeByName, | ||
pgGetGqlTypeByTypeId, | ||
pgSql: sql, | ||
graphql: { GraphQLList, GraphQLNonNull }, | ||
pgIntrospectionResultsByKind: introspectionResultsByKind, | ||
inflection | ||
}, { | ||
scope: { isMutationPayload, pgIntrospection, pgIntrospectionTable }, | ||
fieldWithHooks, | ||
recurseDataGeneratorsForField, | ||
Self | ||
}) => { | ||
builder.hook("GraphQLObjectType:fields", (fields, build, context) => { | ||
const { | ||
extend, | ||
getTypeByName, | ||
pgGetGqlTypeByTypeId, | ||
pgSql: sql, | ||
graphql: { GraphQLList, GraphQLNonNull }, | ||
pgIntrospectionResultsByKind: introspectionResultsByKind, | ||
inflection | ||
} = build; | ||
const { | ||
scope: { isMutationPayload, pgIntrospection, pgIntrospectionTable }, | ||
fieldWithHooks, | ||
recurseDataGeneratorsForField, | ||
Self | ||
} = context; | ||
const table = pgIntrospectionTable || pgIntrospection; | ||
@@ -34,0 +36,0 @@ if (!isMutationPayload || !table || table.kind !== "class" || !table.namespace || !table.isSelectable || (0, _omit2.default)(table, "all") && (0, _omit2.default)(table, "many")) { |
@@ -18,6 +18,3 @@ "use strict"; | ||
exports.default = function PgMutationProceduresPlugin(builder) { | ||
builder.hook("GraphQLObjectType:fields", (fields, build, { scope: { isRootMutation }, fieldWithHooks }) => { | ||
if (!isRootMutation) { | ||
return fields; | ||
} | ||
builder.hook("GraphQLObjectType:fields", (fields, build, context) => { | ||
const { | ||
@@ -28,17 +25,21 @@ extend, | ||
} = build; | ||
const { scope: { isRootMutation }, fieldWithHooks } = context; | ||
if (!isRootMutation) { | ||
return fields; | ||
} | ||
return extend(fields, introspectionResultsByKind.procedure.filter(proc => !proc.isStable).filter(proc => !!proc.namespace).filter(proc => !(0, _omit2.default)(proc, "execute")).reduce((memo, proc) => { | ||
/* | ||
proc = | ||
{ kind: 'procedure', | ||
name: 'integration_webhook_secret', | ||
description: null, | ||
namespaceId: '6484381', | ||
isStrict: false, | ||
returnsSet: false, | ||
isStable: true, | ||
returnTypeId: '2950', | ||
argTypeIds: [ '6484569' ], | ||
argNames: [ 'integration' ], | ||
argDefaultsNum: 0 } | ||
*/ | ||
proc = | ||
{ kind: 'procedure', | ||
name: 'integration_webhook_secret', | ||
description: null, | ||
namespaceId: '6484381', | ||
isStrict: false, | ||
returnsSet: false, | ||
isStable: true, | ||
returnTypeId: '2950', | ||
argTypeIds: [ '6484569' ], | ||
argNames: [ 'integration' ], | ||
argDefaultsNum: 0 } | ||
*/ | ||
@@ -45,0 +46,0 @@ const fieldName = inflection.functionMutationName(proc); |
@@ -33,3 +33,3 @@ "use strict"; | ||
} | ||
builder.hook("GraphQLObjectType:fields", (fields, build, { scope: { isRootMutation }, fieldWithHooks }) => { | ||
builder.hook("GraphQLObjectType:fields", (fields, build, context) => { | ||
const { | ||
@@ -59,2 +59,3 @@ newWithHooks, | ||
} = build; | ||
const { scope: { isRootMutation }, fieldWithHooks } = context; | ||
const { pluralize, singularize, camelCase } = inflection; | ||
@@ -211,5 +212,3 @@ if (!isRootMutation) { | ||
memo[fieldName] = fieldWithHooks(fieldName, context => { | ||
const { | ||
getDataFromParsedResolveInfoFragment | ||
} = context; | ||
const { getDataFromParsedResolveInfoFragment } = context; | ||
return { | ||
@@ -292,5 +291,3 @@ description: mode === "update" ? `Updates a single \`${tableTypeName}\` using its globally unique id and a patch.` : `Deletes a single \`${tableTypeName}\` using its globally unique id.`, | ||
memo[fieldName] = fieldWithHooks(fieldName, context => { | ||
const { | ||
getDataFromParsedResolveInfoFragment | ||
} = context; | ||
const { getDataFromParsedResolveInfoFragment } = context; | ||
return { | ||
@@ -297,0 +294,0 @@ description: mode === "update" ? `Updates a single \`${tableTypeName}\` using a unique key and a patch.` : `Deletes a single \`${tableTypeName}\` using a unique key.`, |
@@ -8,3 +8,7 @@ "use strict"; | ||
exports.default = async function PgNodeAliasPostGraphile(builder) { | ||
builder.hook("GraphQLObjectType", (object, { setNodeAlias, inflection: { pluralize } }, { scope: { isPgRowType, isPgCompoundType, pgIntrospection: table } }) => { | ||
builder.hook("GraphQLObjectType", (object, build, context) => { | ||
const { setNodeAlias, inflection: { pluralize } } = build; | ||
const { | ||
scope: { isPgRowType, isPgCompoundType, pgIntrospection: table } | ||
} = context; | ||
if (isPgRowType || isPgCompoundType) { | ||
@@ -11,0 +15,0 @@ setNodeAlias(object.name, pluralize(table.name)); |
@@ -8,3 +8,8 @@ "use strict"; | ||
exports.default = function PgOrderByPrimaryKeyPlugin(builder) { | ||
builder.hook("GraphQLEnumType:values", (values, { extend, pgIntrospectionResultsByKind: introspectionResultsByKind }, { scope: { isPgRowSortEnum, pgIntrospection: table } }) => { | ||
builder.hook("GraphQLEnumType:values", (values, build, context) => { | ||
const { | ||
extend, | ||
pgIntrospectionResultsByKind: introspectionResultsByKind | ||
} = build; | ||
const { scope: { isPgRowSortEnum, pgIntrospection: table } } = context; | ||
if (!isPgRowSortEnum || !table || table.kind !== "class") { | ||
@@ -11,0 +16,0 @@ return values; |
@@ -30,6 +30,3 @@ "use strict"; | ||
const hasSimpleCollections = pgSimpleCollections === "only" || pgSimpleCollections === "both"; | ||
builder.hook("GraphQLObjectType:fields", (fields, build, { scope: { isRootQuery }, fieldWithHooks }) => { | ||
if (!isRootQuery) { | ||
return fields; | ||
} | ||
builder.hook("GraphQLObjectType:fields", (fields, build, context) => { | ||
const { | ||
@@ -40,17 +37,21 @@ extend, | ||
} = build; | ||
const { scope: { isRootQuery }, fieldWithHooks } = context; | ||
if (!isRootQuery) { | ||
return fields; | ||
} | ||
return extend(fields, introspectionResultsByKind.procedure.filter(proc => proc.isStable).filter(proc => !!proc.namespace).filter(proc => !(0, _omit2.default)(proc, "execute")).reduce((memo, proc) => { | ||
/* | ||
proc = | ||
{ kind: 'procedure', | ||
name: 'integration_webhook_secret', | ||
description: null, | ||
namespaceId: '6484381', | ||
isStrict: false, | ||
returnsSet: false, | ||
isStable: true, | ||
returnTypeId: '2950', | ||
argTypeIds: [ '6484569' ], | ||
argNames: [ 'integration' ], | ||
argDefaultsNum: 0 } | ||
*/ | ||
proc = | ||
{ kind: 'procedure', | ||
name: 'integration_webhook_secret', | ||
description: null, | ||
namespaceId: '6484381', | ||
isStrict: false, | ||
returnsSet: false, | ||
isStable: true, | ||
returnTypeId: '2950', | ||
argTypeIds: [ '6484569' ], | ||
argNames: [ 'integration' ], | ||
argDefaultsNum: 0 } | ||
*/ | ||
const argTypes = proc.argTypeIds.map(typeId => introspectionResultsByKind.typeById[typeId]); | ||
@@ -57,0 +58,0 @@ if (argTypes.some(type => type.type === "c" && type.class && type.class.isSelectable)) { |
@@ -24,13 +24,15 @@ "use strict"; | ||
exports.default = async function PgRowByUniqueConstraint(builder) { | ||
builder.hook("GraphQLObjectType:fields", (fields, { | ||
extend, | ||
parseResolveInfo, | ||
pgGetGqlTypeByTypeId, | ||
pgGetGqlInputTypeByTypeId, | ||
gql2pg, | ||
pgIntrospectionResultsByKind: introspectionResultsByKind, | ||
pgSql: sql, | ||
graphql: { GraphQLNonNull }, | ||
inflection | ||
}, { scope: { isRootQuery }, fieldWithHooks }) => { | ||
builder.hook("GraphQLObjectType:fields", (fields, build, context) => { | ||
const { | ||
extend, | ||
parseResolveInfo, | ||
pgGetGqlTypeByTypeId, | ||
pgGetGqlInputTypeByTypeId, | ||
gql2pg, | ||
pgIntrospectionResultsByKind: introspectionResultsByKind, | ||
pgSql: sql, | ||
graphql: { GraphQLNonNull }, | ||
inflection | ||
} = build; | ||
const { scope: { isRootQuery }, fieldWithHooks } = context; | ||
if (!isRootQuery) { | ||
@@ -37,0 +39,0 @@ return fields; |
@@ -25,8 +25,10 @@ "use strict"; | ||
exports.default = async function PgRowByUniqueConstraint(builder) { | ||
builder.hook("GraphQLObjectType", (object, { | ||
addNodeFetcherForTypeName, | ||
pgIntrospectionResultsByKind: introspectionResultsByKind, | ||
pgSql: sql, | ||
gql2pg | ||
}, { scope: { isPgRowType, pgIntrospection: table } }) => { | ||
builder.hook("GraphQLObjectType", (object, build, context) => { | ||
const { | ||
addNodeFetcherForTypeName, | ||
pgIntrospectionResultsByKind: introspectionResultsByKind, | ||
pgSql: sql, | ||
gql2pg | ||
} = build; | ||
const { scope: { isPgRowType, pgIntrospection: table } } = context; | ||
if (!isPgRowType || !table.namespace || (0, _omit2.default)(table, "read")) { | ||
@@ -59,14 +61,16 @@ return object; | ||
builder.hook("GraphQLObjectType:fields", (fields, { | ||
nodeIdFieldName, | ||
extend, | ||
parseResolveInfo, | ||
pgGetGqlTypeByTypeId, | ||
pgIntrospectionResultsByKind: introspectionResultsByKind, | ||
pgSql: sql, | ||
gql2pg, | ||
getNodeType, | ||
graphql: { GraphQLNonNull, GraphQLID }, | ||
inflection | ||
}, { scope: { isRootQuery }, fieldWithHooks }) => { | ||
builder.hook("GraphQLObjectType:fields", (fields, build, context) => { | ||
const { | ||
nodeIdFieldName, | ||
extend, | ||
parseResolveInfo, | ||
pgGetGqlTypeByTypeId, | ||
pgIntrospectionResultsByKind: introspectionResultsByKind, | ||
pgSql: sql, | ||
gql2pg, | ||
getNodeType, | ||
graphql: { GraphQLNonNull, GraphQLID }, | ||
inflection | ||
} = build; | ||
const { scope: { isRootQuery }, fieldWithHooks } = context; | ||
if (!isRootQuery || !nodeIdFieldName) { | ||
@@ -73,0 +77,0 @@ return fields; |
@@ -16,15 +16,16 @@ "use strict"; | ||
exports.default = function PgScalarFunctionConnectionPlugin(builder, { pgForbidSetofFunctionsToReturnNull = false }) { | ||
builder.hook("init", (_, { | ||
newWithHooks, | ||
pgIntrospectionResultsByKind: introspectionResultsByKind, | ||
getTypeByName, | ||
pgGetGqlTypeByTypeId, | ||
graphql: { | ||
GraphQLObjectType, | ||
GraphQLNonNull, | ||
GraphQLList, | ||
GraphQLString | ||
}, | ||
inflection | ||
}) => { | ||
builder.hook("init", (_, build) => { | ||
const { | ||
newWithHooks, | ||
pgIntrospectionResultsByKind: introspectionResultsByKind, | ||
getTypeByName, | ||
pgGetGqlTypeByTypeId, | ||
graphql: { | ||
GraphQLObjectType, | ||
GraphQLNonNull, | ||
GraphQLList, | ||
GraphQLString | ||
}, | ||
inflection | ||
} = build; | ||
const nullableIf = (condition, Type) => condition ? Type : new GraphQLNonNull(Type); | ||
@@ -31,0 +32,0 @@ const Cursor = getTypeByName("Cursor"); |
@@ -142,3 +142,3 @@ "use strict"; | ||
// so this should not cause any issues in practice. | ||
if (/^[_A-Za-z][_0-9A-Za-z]*$/.test(alias) !== true) { | ||
if (/^@*[_A-Za-z][_0-9A-Za-z]*$/.test(alias) !== true) { | ||
throw new Error(`Disallowed alias '${alias}'.`); | ||
@@ -310,3 +310,3 @@ } | ||
this.lockEverything(); | ||
let buildObject = this.compiledData.select.length ? sql.fragment`json_build_object(${sql.join(this.compiledData.select.map(([sqlFragment, alias]) => sql.fragment`${sql.literal(alias)}, ${sqlFragment}`), ", ")})` : sql.fragment`to_json(${this.getTableAlias()})`; | ||
let buildObject = this.compiledData.select.length ? sql.fragment`json_build_object(${sql.join(this.compiledData.select.map(([sqlFragment, alias]) => sql.fragment`${sql.literal(alias)}::text, ${sqlFragment}`), ", ")})` : sql.fragment`to_json(${this.getTableAlias()})`; | ||
if (addNullCase) { | ||
@@ -313,0 +313,0 @@ buildObject = sql.fragment`(case when ${this.getTableAlias()} is not distinct from null then null else ${buildObject} end)`; |
@@ -193,3 +193,3 @@ "use strict"; | ||
} else { | ||
return _pgSql2.default.fragment`${sqlWith} select json_build_object(${_pgSql2.default.join(fields.map(([expr, alias]) => _pgSql2.default.fragment`${_pgSql2.default.literal(alias)}, ${expr}`), ", ")}) ${sqlFrom}`; | ||
return _pgSql2.default.fragment`${sqlWith} select json_build_object(${_pgSql2.default.join(fields.map(([expr, alias]) => _pgSql2.default.fragment`${_pgSql2.default.literal(alias)}::text, ${expr}`), ", ")}) ${sqlFrom}`; | ||
} | ||
@@ -196,0 +196,0 @@ } else { |
{ | ||
"name": "graphile-build-pg", | ||
"version": "4.0.0-beta.7.2", | ||
"version": "4.0.0-beta.8", | ||
"description": "Build a GraphQL schema by reflection over a PostgreSQL schema. Easy to customize since it's built with plugins on graphile-build", | ||
@@ -39,3 +39,3 @@ "main": "node8plus/index.js", | ||
"debug": ">=2 <3", | ||
"graphile-build": "4.0.0-beta.7.2", | ||
"graphile-build": "4.0.0-beta.8", | ||
"graphql-iso-date": "^3.2.0", | ||
@@ -45,3 +45,3 @@ "jsonwebtoken": "^8.1.1", | ||
"lru-cache": "4.1.1", | ||
"pg-sql2": "2.0.0", | ||
"pg-sql2": "2.1.0", | ||
"postgres-interval": "1.1.1" | ||
@@ -48,0 +48,0 @@ }, |
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
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
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
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
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
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
5443
988349
+ Addedgraphile-build@4.0.0-beta.8(transitive)
+ Addedgraphql-parse-resolve-info@4.0.0-beta.8(transitive)
+ Addedpg-sql2@2.1.0(transitive)
- Removedgraphile-build@4.0.0-beta.7.2(transitive)
- Removedgraphql-parse-resolve-info@4.0.0-beta.7.2(transitive)
- Removedpg-sql2@2.0.0(transitive)
Updatedgraphile-build@4.0.0-beta.8
Updatedpg-sql2@2.1.0