Skip to content

Commit 2fd57df

Browse files
authored
Forward relations (#54)
Support filtering on forward relations
1 parent 9119ab3 commit 2fd57df

11 files changed

+3411
-9
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
query {
2+
parent_name_equalTo_parent2: allFilterables(filter: {parentByParentId: {name: {equalTo: "parent2"}}}) { ...filterableConnection }
3+
forward_name_equalTo_forward2: allFilterables(filter: {forwardByForwardId: {name: {equalTo: "forward2"}}}) { ...filterableConnection }
4+
}
5+
6+
fragment filterableConnection on FilterablesConnection {
7+
nodes {
8+
id
9+
string
10+
}
11+
}

__tests__/integration/__snapshots__/queries.test.js.snap

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,6 +1856,33 @@ Object {
18561856
}
18571857
`;
18581858

1859+
exports[`connections-filter.relations.graphql 1`] = `
1860+
Object {
1861+
"data": Object {
1862+
"forward_name_equalTo_forward2": Object {
1863+
"nodes": Array [
1864+
Object {
1865+
"id": 2,
1866+
"string": "Test",
1867+
},
1868+
],
1869+
},
1870+
"parent_name_equalTo_parent2": Object {
1871+
"nodes": Array [
1872+
Object {
1873+
"id": 3,
1874+
"string": "tEST",
1875+
},
1876+
Object {
1877+
"id": 4,
1878+
"string": "test",
1879+
},
1880+
],
1881+
},
1882+
},
1883+
}
1884+
`;
1885+
18591886
exports[`connections-filter.simple-collections.graphql 1`] = `
18601887
Object {
18611888
"data": Object {

__tests__/integration/queries.test.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,25 @@ beforeAll(() => {
2727
// Different fixtures need different schemas with different configurations.
2828
// Make all of the different schemas with different configurations that we
2929
// need and wait for them to be created in parallel.
30-
const [normal, dynamicJson, simpleCollections] = await Promise.all([
30+
const [
31+
normal,
32+
dynamicJson,
33+
relations,
34+
simpleCollections,
35+
] = await Promise.all([
3136
createPostGraphileSchema(pgClient, ["p"], {
3237
appendPlugins: [require("../../index.js")],
3338
}),
3439
createPostGraphileSchema(pgClient, ["p"], {
3540
dynamicJson: true,
3641
appendPlugins: [require("../../index.js")],
3742
}),
43+
createPostGraphileSchema(pgClient, ["p"], {
44+
appendPlugins: [require("../../index.js")],
45+
graphileBuildOptions: {
46+
connectionFilterRelations: true,
47+
},
48+
}),
3849
createPostGraphileSchema(pgClient, ["p"], {
3950
simpleCollections: "only",
4051
appendPlugins: [require("../../index.js")],
@@ -44,6 +55,7 @@ beforeAll(() => {
4455
return {
4556
normal,
4657
dynamicJson,
58+
relations,
4759
simpleCollections,
4860
};
4961
});
@@ -73,6 +85,7 @@ beforeAll(() => {
7385
// differently.
7486
const schemas = {
7587
"connections-filter.dynamic-json.graphql": gqlSchemas.dynamicJson,
88+
"connections-filter.relations.graphql": gqlSchemas.relations,
7689
"connections-filter.simple-collections.graphql":
7790
gqlSchemas.simpleCollections,
7891
};

0 commit comments

Comments
 (0)