Skip to content

Commit 215f5cf

Browse files
jcgsvilleChandler Gonzalesbenjie
authored
feat(pg): support domain constrained composite types (#615)
Co-authored-by: Chandler Gonzales <cgonzales@logixboard.com> Co-authored-by: Benjie Gillam <benjie@jemjie.com>
1 parent 576177f commit 215f5cf

8 files changed

Lines changed: 299 additions & 7 deletions

File tree

packages/graphile-build-pg/src/plugins/PgTypesPlugin.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,10 +1001,10 @@ end`;
10011001
type.domainBaseTypeId,
10021002
typeModifier
10031003
);
1004-
const baseInputType =
1005-
gqlInputTypeByTypeIdAndModifier[type.domainBaseTypeId][
1006-
typeModifierKey
1007-
];
1004+
const baseInputType = getGqlInputTypeByTypeIdAndModifier(
1005+
type.domainBaseTypeId,
1006+
typeModifier
1007+
);
10081008
// Hack stolen from: https://github.com/graphile/postgraphile/blob/ade728ed8f8e3ecdc5fdad7d770c67aa573578eb/src/graphql/schema/type/aliasGqlType.ts#L16
10091009
gqlTypeByTypeIdAndModifier[type.id][typeModifierKey] = Object.assign(
10101010
Object.create(baseType),

packages/postgraphile-core/__tests__/fixtures/mutations/pg11.types.graphql

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ mutation {
1111
"2098288669218571760"
1212
"2098288669218571761"
1313
]
14+
domainConstrainedCompoundType: { a: 1 }
1415
}
1516
}
1617
) {
@@ -29,6 +30,7 @@ mutation {
2930
"2098288669218571760"
3031
"2098288669218571761"
3132
]
33+
domainConstrainedCompoundType: { a: 1 }
3234
}
3335
}
3436
) {
@@ -43,4 +45,17 @@ fragment type on Type {
4345
regrole
4446
regnamespace
4547
bigintDomainArrayDomain
48+
domainConstrainedCompoundType {
49+
...domainConstrainedCompoundType
50+
}
51+
}
52+
53+
fragment domainConstrainedCompoundType on DomainConstrainedCompoundType {
54+
a
55+
b
56+
c
57+
d
58+
e
59+
f
60+
fooBar
4661
}

packages/postgraphile-core/__tests__/fixtures/queries/pg11.types.graphql

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@ fragment type on Type {
99
regrole
1010
regnamespace
1111
bigintDomainArrayDomain
12+
domainConstrainedCompoundType {
13+
...domainConstrainedCompoundType
14+
}
15+
}
16+
17+
fragment domainConstrainedCompoundType on DomainConstrainedCompoundType {
18+
a
19+
b
20+
c
21+
d
22+
e
23+
f
24+
fooBar
1225
}
1326

1427
fragment typesConnection on TypesConnection {

packages/postgraphile-core/__tests__/integration/__snapshots__/mutations.test.js.snap

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,6 +1395,15 @@ Object {
13951395
"2098288669218571760",
13961396
"2098288669218571761",
13971397
],
1398+
"domainConstrainedCompoundType": Object {
1399+
"a": 1,
1400+
"b": null,
1401+
"c": null,
1402+
"d": null,
1403+
"e": null,
1404+
"f": null,
1405+
"fooBar": null,
1406+
},
13981407
"id": 15,
13991408
"regnamespace": "c",
14001409
"regrole": "postgraphile_test_visitor",
@@ -1407,6 +1416,15 @@ Object {
14071416
"2098288669218571760",
14081417
"2098288669218571761",
14091418
],
1419+
"domainConstrainedCompoundType": Object {
1420+
"a": 1,
1421+
"b": null,
1422+
"c": null,
1423+
"d": null,
1424+
"e": null,
1425+
"f": null,
1426+
"fooBar": null,
1427+
},
14101428
"id": 12,
14111429
"regnamespace": "pg11",
14121430
"regrole": "postgraphile_test_authenticator",

packages/postgraphile-core/__tests__/integration/__snapshots__/queries.test.js.snap

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2976,6 +2976,7 @@ Object {
29762976
Object {
29772977
"node": Object {
29782978
"bigintDomainArrayDomain": null,
2979+
"domainConstrainedCompoundType": null,
29792980
"id": 11,
29802981
"regnamespace": null,
29812982
"regrole": null,
@@ -2988,6 +2989,15 @@ Object {
29882989
"2",
29892990
"2098288669218571760",
29902991
],
2992+
"domainConstrainedCompoundType": Object {
2993+
"a": 1,
2994+
"b": "2",
2995+
"c": "BLUE",
2996+
"d": "4be8a712-3ff7-432e-aa34-fdb43fbd838d",
2997+
"e": "FOO_BAR",
2998+
"f": "_EMPTY_",
2999+
"fooBar": null,
3000+
},
29913001
"id": 12,
29923002
"regnamespace": "b",
29933003
"regrole": "postgraphile_test_authenticator",
@@ -2997,6 +3007,7 @@ Object {
29973007
"nodes": Array [
29983008
Object {
29993009
"bigintDomainArrayDomain": null,
3010+
"domainConstrainedCompoundType": null,
30003011
"id": 11,
30013012
"regnamespace": null,
30023013
"regrole": null,
@@ -3007,6 +3018,15 @@ Object {
30073018
"2",
30083019
"2098288669218571760",
30093020
],
3021+
"domainConstrainedCompoundType": Object {
3022+
"a": 1,
3023+
"b": "2",
3024+
"c": "BLUE",
3025+
"d": "4be8a712-3ff7-432e-aa34-fdb43fbd838d",
3026+
"e": "FOO_BAR",
3027+
"f": "_EMPTY_",
3028+
"fooBar": null,
3029+
},
30103030
"id": 12,
30113031
"regnamespace": "b",
30123032
"regrole": "postgraphile_test_authenticator",

0 commit comments

Comments
 (0)