Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/graphile-build-pg/src/QueryBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ function escapeLarge(sqlFragment: SQL, type: PgType) {
"23" /* int4 */,
"700" /* float4 */,
"701" /* float8 */,
"24" /* regproc */,
"2202" /* regprocedure */,
"2203" /* regoper */,
"2204" /* regoperator */,
"2205" /* regclass */,
"2206" /* regtype */,
"4096" /* regrole */,
"4089" /* regnamespace */,
"3734" /* regconfig */,
"3769" /* regdictionary */,
].includes(actualType.id)
) {
// No need for special handling
Expand Down
60 changes: 60 additions & 0 deletions packages/graphile-build-pg/src/plugins/PgTypesPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,46 @@ export default (function PgTypesPlugin(
inflection.builtin("InternetAddress"),
"An IPv4 or IPv6 host address, and optionally its subnet."
);
const RegProcType = stringType(
inflection.builtin("RegProc"),
"A builtin object identifier type for a function name"
);
const RegProcedureType = stringType(
inflection.builtin("RegProcedure"),
"A builtin object identifier type for a function with argument types"
);
const RegOperType = stringType(
inflection.builtin("RegOper"),
"A builtin object identifier type for an operator"
);
const RegOperatorType = stringType(
inflection.builtin("RegOperator"),
"A builtin object identifier type for an operator with argument types"
);
const RegClassType = stringType(
inflection.builtin("RegClass"),
"A builtin object identifier type for a relation name"
);
const RegTypeType = stringType(
inflection.builtin("RegType"),
"A builtin object identifier type for a data type name"
);
const RegRoleType = stringType(
inflection.builtin("RegRole"),
"A builtin object identifier type for a role name"
);
const RegNamespaceType = stringType(
inflection.builtin("RegNamespace"),
"A builtin object identifier type for a namespace name"
);
const RegConfigType = stringType(
inflection.builtin("RegConfig"),
"A builtin object identifier type for a text search configuration"
);
const RegDictionaryType = stringType(
inflection.builtin("RegDictionary"),
"A builtin object identifier type for a text search dictionary"
);
const CidrType = pgUseCustomNetworkScalars
? stringType(
inflection.builtin("CidrAddress"),
Expand Down Expand Up @@ -424,6 +464,16 @@ export default (function PgTypesPlugin(
addType(DateType, "graphile-build-pg built-in");
addType(DateTimeType, "graphile-build-pg built-in");
addType(TimeType, "graphile-build-pg built-in");
addType(RegProcType, "graphile-build-pg built-in");
addType(RegProcedureType, "graphile-build-pg built-in");
addType(RegOperType, "graphile-build-pg built-in");
addType(RegOperatorType, "graphile-build-pg built-in");
addType(RegClassType, "graphile-build-pg built-in");
addType(RegTypeType, "graphile-build-pg built-in");
addType(RegRoleType, "graphile-build-pg built-in");
addType(RegNamespaceType, "graphile-build-pg built-in");
addType(RegConfigType, "graphile-build-pg built-in");
addType(RegDictionaryType, "graphile-build-pg built-in");

const oidLookup = {
20: stringType(
Expand Down Expand Up @@ -461,6 +511,16 @@ export default (function PgTypesPlugin(
650: CidrType,
829: MacAddrType,
774: MacAddr8Type,
24: RegProcType,
2202: RegProcedureType,
2203: RegOperType,
2204: RegOperatorType,
2205: RegClassType,
2206: RegTypeType,
4096: RegRoleType,
4089: RegNamespaceType,
3734: RegConfigType,
3769: RegDictionaryType,
};
const oidInputLookup = {
1186: GQLIntervalInput, // interval
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
mutation {
# Must come next to last
updateTypeById(
input: {
id: 12
typePatch: {
regrole: "postgraphile_test_authenticator"
regnamespace: "pg10"
}
}
) {
type {
...type
}
}
# Must come last
createType(
input: {
type: {
regrole: "postgraphile_test_visitor"
regnamespace: "c"
}
}
) {
type {
...type
}
}
}

fragment type on Type {
regrole
regnamespace
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ mutation {
money: 27
compoundType: { a: 1 }
nestedCompoundType: { a: { a: 1 } }
regproc: "b.type_function"
regprocedure: "b.type_function(int)"
regoper: "*<>"
regoperator: "+(integer, integer)"
regclass: "c.person"
regtype: "numeric"
regconfig: "dutch"
regdictionary: "dutch_stem"
}
}
) {
Expand Down Expand Up @@ -102,6 +110,14 @@ mutation {
money: 27
compoundType: { a: 1 }
nestedCompoundType: { a: { a: 1 } }
regproc: "b.type_function"
regprocedure: "b.type_function(int)"
regoper: "*<>"
regoperator: "+(integer, integer)"
regclass: "c.person"
regtype: "numeric"
regconfig: "dutch"
regdictionary: "dutch_stem"
}
}
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
query {
allTypes {
...typesConnection
}
}

fragment type on Type {
regrole
regnamespace
}

fragment typesConnection on TypesConnection {
nodes {
...type
}
edges {
node {
...type
}
}
totalCount
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ fragment type on Type {
textArray
json
jsonb
regproc
regprocedure
regoper
regoperator
regclass
regtype
regconfig
regdictionary
nullableRange {
start {
value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1369,6 +1369,25 @@ Object {
}
`;

exports[`pg10.types.graphql 1`] = `
Object {
"data": Object {
"createType": Object {
"type": Object {
"regnamespace": "c",
"regrole": "postgraphile_test_visitor",
},
},
"updateTypeById": Object {
"type": Object {
"regnamespace": "pg10",
"regrole": "postgraphile_test_authenticator",
},
},
},
}
`;

exports[`procedure-mutation.graphql 1`] = `
Object {
"data": Object {
Expand Down
Loading