graphile-build-pg 4.13.0 → 4.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -13
- package/node8plus/GraphQLJSON.js +0 -11
- package/node8plus/GraphQLJSON.js.map +1 -1
- package/node8plus/PgLiveProvider.js +4 -11
- package/node8plus/PgLiveProvider.js.map +1 -1
- package/node8plus/QueryBuilder.js +42 -176
- package/node8plus/QueryBuilder.js.map +1 -1
- package/node8plus/index.js +8 -47
- package/node8plus/index.js.map +1 -1
- package/node8plus/inflections.js +9 -61
- package/node8plus/inflections.js.map +1 -1
- package/node8plus/omit.js +7 -22
- package/node8plus/omit.js.map +1 -1
- package/node8plus/parseIdentifier.js +0 -1
- package/node8plus/parseIdentifier.js.map +1 -1
- package/node8plus/pgPrepareAndRun.js +2 -14
- package/node8plus/pgPrepareAndRun.js.map +1 -1
- package/node8plus/plugins/PageInfoStartEndCursor.js +0 -4
- package/node8plus/plugins/PageInfoStartEndCursor.js.map +1 -1
- package/node8plus/plugins/PgAllRows.js +0 -29
- package/node8plus/plugins/PgAllRows.js.map +1 -1
- package/node8plus/plugins/PgBackwardRelationPlugin.js +2 -41
- package/node8plus/plugins/PgBackwardRelationPlugin.js.map +1 -1
- package/node8plus/plugins/PgBasicsPlugin.js +20 -147
- package/node8plus/plugins/PgBasicsPlugin.js.map +1 -1
- package/node8plus/plugins/PgColumnDeprecationPlugin.js +2 -5
- package/node8plus/plugins/PgColumnDeprecationPlugin.js.map +1 -1
- package/node8plus/plugins/PgColumnsPlugin.js +4 -17
- package/node8plus/plugins/PgColumnsPlugin.js.map +1 -1
- package/node8plus/plugins/PgComputedColumnsPlugin.js +4 -19
- package/node8plus/plugins/PgComputedColumnsPlugin.js.map +1 -1
- package/node8plus/plugins/PgConditionComputedColumnPlugin.js +12 -23
- package/node8plus/plugins/PgConditionComputedColumnPlugin.js.map +1 -1
- package/node8plus/plugins/PgConnectionArgCondition.js +1 -9
- package/node8plus/plugins/PgConnectionArgCondition.js.map +1 -1
- package/node8plus/plugins/PgConnectionArgFirstLastBeforeAfter.js +0 -12
- package/node8plus/plugins/PgConnectionArgFirstLastBeforeAfter.js.map +1 -1
- package/node8plus/plugins/PgConnectionArgOrderBy.js +2 -19
- package/node8plus/plugins/PgConnectionArgOrderBy.js.map +1 -1
- package/node8plus/plugins/PgConnectionArgOrderByDefaultValue.js +0 -6
- package/node8plus/plugins/PgConnectionArgOrderByDefaultValue.js.map +1 -1
- package/node8plus/plugins/PgConnectionTotalCount.js +0 -8
- package/node8plus/plugins/PgConnectionTotalCount.js.map +1 -1
- package/node8plus/plugins/PgForwardRelationPlugin.js +2 -25
- package/node8plus/plugins/PgForwardRelationPlugin.js.map +1 -1
- package/node8plus/plugins/PgIntrospectionPlugin.js +91 -180
- package/node8plus/plugins/PgIntrospectionPlugin.js.flow +30 -2
- package/node8plus/plugins/PgIntrospectionPlugin.js.map +1 -1
- package/node8plus/plugins/PgJWTPlugin.js +2 -18
- package/node8plus/plugins/PgJWTPlugin.js.map +1 -1
- package/node8plus/plugins/PgMutationCreatePlugin.js +0 -18
- package/node8plus/plugins/PgMutationCreatePlugin.js.map +1 -1
- package/node8plus/plugins/PgMutationPayloadEdgePlugin.js +4 -25
- package/node8plus/plugins/PgMutationPayloadEdgePlugin.js.map +1 -1
- package/node8plus/plugins/PgMutationProceduresPlugin.js +0 -6
- package/node8plus/plugins/PgMutationProceduresPlugin.js.map +1 -1
- package/node8plus/plugins/PgMutationUpdateDeletePlugin.js +14 -49
- package/node8plus/plugins/PgMutationUpdateDeletePlugin.js.flow +5 -2
- package/node8plus/plugins/PgMutationUpdateDeletePlugin.js.map +1 -1
- package/node8plus/plugins/PgNodeAliasPostGraphile.js +0 -6
- package/node8plus/plugins/PgNodeAliasPostGraphile.js.map +1 -1
- package/node8plus/plugins/PgOrderAllColumnsPlugin.js +0 -4
- package/node8plus/plugins/PgOrderAllColumnsPlugin.js.map +1 -1
- package/node8plus/plugins/PgOrderByPrimaryKeyPlugin.js +0 -6
- package/node8plus/plugins/PgOrderByPrimaryKeyPlugin.js.map +1 -1
- package/node8plus/plugins/PgOrderComputedColumnsPlugin.js +10 -14
- package/node8plus/plugins/PgOrderComputedColumnsPlugin.js.map +1 -1
- package/node8plus/plugins/PgQueryProceduresPlugin.js +4 -16
- package/node8plus/plugins/PgQueryProceduresPlugin.js.map +1 -1
- package/node8plus/plugins/PgRecordFunctionConnectionPlugin.js +3 -20
- package/node8plus/plugins/PgRecordFunctionConnectionPlugin.js.map +1 -1
- package/node8plus/plugins/PgRecordReturnTypesPlugin.js +11 -16
- package/node8plus/plugins/PgRecordReturnTypesPlugin.js.map +1 -1
- package/node8plus/plugins/PgRowByUniqueConstraint.js +4 -25
- package/node8plus/plugins/PgRowByUniqueConstraint.js.map +1 -1
- package/node8plus/plugins/PgRowNode.js +0 -32
- package/node8plus/plugins/PgRowNode.js.map +1 -1
- package/node8plus/plugins/PgScalarFunctionConnectionPlugin.js +3 -17
- package/node8plus/plugins/PgScalarFunctionConnectionPlugin.js.map +1 -1
- package/node8plus/plugins/PgTablesPlugin.js +7 -59
- package/node8plus/plugins/PgTablesPlugin.js.map +1 -1
- package/node8plus/plugins/PgTypesPlugin.js +140 -240
- package/node8plus/plugins/PgTypesPlugin.js.flow +76 -23
- package/node8plus/plugins/PgTypesPlugin.js.map +1 -1
- package/node8plus/plugins/addStartEndCursor.js +2 -5
- package/node8plus/plugins/addStartEndCursor.js.map +1 -1
- package/node8plus/plugins/debugSql.js +1 -16
- package/node8plus/plugins/debugSql.js.map +1 -1
- package/node8plus/plugins/introspectionQuery.js +3 -4
- package/node8plus/plugins/introspectionQuery.js.flow +11 -3
- package/node8plus/plugins/introspectionQuery.js.map +1 -1
- package/node8plus/plugins/makeProcField.js +40 -90
- package/node8plus/plugins/makeProcField.js.map +1 -1
- package/node8plus/plugins/pgField.js +2 -7
- package/node8plus/plugins/pgField.js.map +1 -1
- package/node8plus/plugins/viaTemporaryTable.js +6 -12
- package/node8plus/plugins/viaTemporaryTable.js.map +1 -1
- package/node8plus/postgresInterval.js +4 -4
- package/node8plus/postgresInterval.js.map +1 -1
- package/node8plus/queryFromResolveDataFactory.js +33 -77
- package/node8plus/queryFromResolveDataFactory.js.map +1 -1
- package/node8plus/utils.js +8 -9
- package/node8plus/utils.js.map +1 -1
- package/node8plus/withPgClient.js +4 -26
- package/node8plus/withPgClient.js.map +1 -1
- package/package.json +4 -4
|
@@ -5,6 +5,8 @@ import makeGraphQLJSONType from "../GraphQLJSON";
|
|
|
5
5
|
|
|
6
6
|
import { parseInterval } from "../postgresInterval";
|
|
7
7
|
|
|
8
|
+
const ENUM_DOMAIN_SUFFIX = "_enum_domain";
|
|
9
|
+
|
|
8
10
|
function indent(str) {
|
|
9
11
|
return " " + str.replace(/\n/g, "\n ");
|
|
10
12
|
}
|
|
@@ -30,6 +32,7 @@ export default (function PgTypesPlugin(
|
|
|
30
32
|
build => {
|
|
31
33
|
const {
|
|
32
34
|
pgIntrospectionResultsByKind: introspectionResultsByKind,
|
|
35
|
+
getPgFakeEnumIdentifier,
|
|
33
36
|
getTypeByName,
|
|
34
37
|
pgSql: sql,
|
|
35
38
|
inflection,
|
|
@@ -753,6 +756,10 @@ export default (function PgTypesPlugin(
|
|
|
753
756
|
gqlInputType;
|
|
754
757
|
}
|
|
755
758
|
}
|
|
759
|
+
|
|
760
|
+
// cf https://github.com/graphile/graphile-engine/pull/748#discussion_r650828353
|
|
761
|
+
let shouldSkipAddType = false;
|
|
762
|
+
|
|
756
763
|
// Enums
|
|
757
764
|
if (
|
|
758
765
|
!gqlTypeByTypeIdAndModifier[type.id][typeModifierKey] &&
|
|
@@ -994,30 +1001,72 @@ end`;
|
|
|
994
1001
|
type.type === "d" &&
|
|
995
1002
|
type.domainBaseTypeId
|
|
996
1003
|
) {
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1004
|
+
// might be used as an enum alias: https://github.com/graphile/postgraphile/issues/1500
|
|
1005
|
+
const tagEnumName =
|
|
1006
|
+
type.tags && typeof type.tags.enum === "string"
|
|
1007
|
+
? type.tags.enum
|
|
1008
|
+
: null;
|
|
1009
|
+
const truncatedTypeName =
|
|
1010
|
+
!tagEnumName && type.name.endsWith(ENUM_DOMAIN_SUFFIX)
|
|
1011
|
+
? type.name.slice(0, type.name.length - ENUM_DOMAIN_SUFFIX.length)
|
|
1012
|
+
: null;
|
|
1013
|
+
const underlyingEnumTypeName = tagEnumName || truncatedTypeName;
|
|
1014
|
+
if (underlyingEnumTypeName !== null) {
|
|
1015
|
+
const baseTypeId = getPgFakeEnumIdentifier(
|
|
1016
|
+
type.namespaceName,
|
|
1017
|
+
underlyingEnumTypeName
|
|
1018
|
+
);
|
|
1019
|
+
|
|
1020
|
+
const baseType = getGqlTypeByTypeIdAndModifier(
|
|
1021
|
+
baseTypeId,
|
|
1022
|
+
typeModifierKey
|
|
1023
|
+
);
|
|
1024
|
+
|
|
1025
|
+
const baseInputType = getGqlInputTypeByTypeIdAndModifier(
|
|
1026
|
+
baseTypeId,
|
|
1027
|
+
typeModifierKey
|
|
1028
|
+
);
|
|
1029
|
+
|
|
1030
|
+
if (!baseType || !baseInputType) {
|
|
1031
|
+
if (tagEnumName) {
|
|
1032
|
+
throw new Error(
|
|
1033
|
+
`The domain ${type.name} uses '@enum ${tagEnumName}' to references its underlying enum type, but no type named ${tagEnumName} could be found.`
|
|
1034
|
+
);
|
|
1035
|
+
} else {
|
|
1036
|
+
throw new Error(
|
|
1037
|
+
`The domain ${type.name} references the enum type ${underlyingEnumTypeName}, but no such type could be found.`
|
|
1038
|
+
);
|
|
1039
|
+
}
|
|
1011
1040
|
}
|
|
1012
|
-
|
|
1013
|
-
|
|
1041
|
+
|
|
1042
|
+
gqlTypeByTypeIdAndModifier[type.id][typeModifierKey] = baseType;
|
|
1014
1043
|
gqlInputTypeByTypeIdAndModifier[type.id][typeModifierKey] =
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1044
|
+
baseInputType;
|
|
1045
|
+
shouldSkipAddType = true;
|
|
1046
|
+
} else {
|
|
1047
|
+
const baseType = getGqlTypeByTypeIdAndModifier(
|
|
1048
|
+
type.domainBaseTypeId,
|
|
1049
|
+
typeModifier
|
|
1050
|
+
);
|
|
1051
|
+
const baseInputType = getGqlInputTypeByTypeIdAndModifier(
|
|
1052
|
+
type.domainBaseTypeId,
|
|
1053
|
+
typeModifier
|
|
1054
|
+
);
|
|
1055
|
+
// Hack stolen from: https://github.com/graphile/postgraphile/blob/ade728ed8f8e3ecdc5fdad7d770c67aa573578eb/src/graphql/schema/type/aliasGqlType.ts#L16
|
|
1056
|
+
gqlTypeByTypeIdAndModifier[type.id][typeModifierKey] =
|
|
1057
|
+
Object.assign(Object.create(baseType), {
|
|
1058
|
+
name: inflection.domainType(type),
|
|
1019
1059
|
description: type.description,
|
|
1020
1060
|
});
|
|
1061
|
+
if (baseInputType && baseInputType !== baseType) {
|
|
1062
|
+
gqlInputTypeByTypeIdAndModifier[type.id][typeModifierKey] =
|
|
1063
|
+
Object.assign(Object.create(baseInputType), {
|
|
1064
|
+
name: inflection.inputType(
|
|
1065
|
+
gqlTypeByTypeIdAndModifier[type.id][typeModifierKey]
|
|
1066
|
+
),
|
|
1067
|
+
description: type.description,
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1021
1070
|
}
|
|
1022
1071
|
}
|
|
1023
1072
|
|
|
@@ -1076,9 +1125,13 @@ end`;
|
|
|
1076
1125
|
gqlTypeByTypeIdAndModifier[type.id][typeModifierKey];
|
|
1077
1126
|
}
|
|
1078
1127
|
}
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
)
|
|
1128
|
+
// if its a domain type substituting for an enum table,
|
|
1129
|
+
// adding it creates a duplicate
|
|
1130
|
+
if (!shouldSkipAddType) {
|
|
1131
|
+
addType(
|
|
1132
|
+
getNamedType(gqlTypeByTypeIdAndModifier[type.id][typeModifierKey])
|
|
1133
|
+
);
|
|
1134
|
+
}
|
|
1082
1135
|
return gqlTypeByTypeIdAndModifier[type.id][typeModifierKey];
|
|
1083
1136
|
};
|
|
1084
1137
|
|