Skip to content

Commit

Permalink
Merge pull request #42 from graphile-contrib/simple-collections
Browse files Browse the repository at this point in the history
Support filtering on simple collections
  • Loading branch information
mattbretl authored Jun 21, 2018
2 parents ecf220a + 8cbe0ef commit bad9425
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
query {
string_isNull_true: allFilterablesList(filter: { string: { isNull: true } }) { ...filterableList }
}

fragment filterableList on Filterable {
id
string
int
real
numeric
boolean
}
17 changes: 17 additions & 0 deletions __tests__/integration/__snapshots__/queries.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1791,3 +1791,20 @@ Object {
},
}
`;

exports[`connections-filter.simple-collections.graphql 1`] = `
Object {
"data": Object {
"string_isNull_true": Array [
Object {
"boolean": null,
"id": 5,
"int": null,
"numeric": null,
"real": null,
"string": null,
},
],
},
}
`;
9 changes: 8 additions & 1 deletion __tests__/integration/queries.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,24 @@ beforeAll(() => {
// Different fixtures need different schemas with different configurations.
// Make all of the different schemas with different configurations that we
// need and wait for them to be created in parallel.
const [normal, dynamicJson] = await Promise.all([
const [normal, dynamicJson, simpleCollections] = await Promise.all([
createPostGraphileSchema(pgClient, ["p"], {
appendPlugins: [require("../../index.js")],
}),
createPostGraphileSchema(pgClient, ["p"], {
dynamicJson: true,
appendPlugins: [require("../../index.js")],
}),
createPostGraphileSchema(pgClient, ["p"], {
simpleCollections: "only",
appendPlugins: [require("../../index.js")],
}),
]);
debug(printSchema(normal));
return {
normal,
dynamicJson,
simpleCollections,
};
});

Expand Down Expand Up @@ -68,6 +73,8 @@ beforeAll(() => {
// differently.
const schemas = {
"connections-filter.dynamic-json.graphql": gqlSchemas.dynamicJson,
"connections-filter.simple-collections.graphql":
gqlSchemas.simpleCollections,
};
const gqlSchema = schemas[fileName]
? schemas[fileName]
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"graphql": ">=0.9 <0.14",
"jest": "^20.0.4",
"pg": ">=6.1.0 <8",
"postgraphile-core": "^4.0.0-beta.6",
"postgraphile-core": "^4.0.0-beta.8",
"prettier": "^1.4.4"
},
"jest": {
Expand Down
9 changes: 7 additions & 2 deletions src/PgConnectionArgFilterPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,18 @@ module.exports = function PgConnectionArgFilterPlugin(
connectionFilterOperators,
} = build;
const {
scope: { isPgFieldConnection, pgFieldIntrospection: source },
scope: {
isPgFieldConnection,
isPgFieldSimpleCollection,
pgFieldIntrospection: source,
},
addArgDataGenerator,
field,
Self,
} = context;
const shouldAddFilter = isPgFieldConnection || isPgFieldSimpleCollection;
if (
!isPgFieldConnection ||
!shouldAddFilter ||
!source ||
(source.kind !== "class" &&
(source.kind !== "procedure" || !connectionFilterSetofFunctions)) ||
Expand Down
40 changes: 20 additions & 20 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1146,36 +1146,36 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.2:
version "4.1.11"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"

[email protected]:
version "4.0.0-beta.6"
resolved "https://registry.yarnpkg.com/graphile-build-pg/-/graphile-build-pg-4.0.0-beta.6.tgz#9ba7d7ea2a19273c34446b3e8ec4a88fdb80121f"
[email protected]rc.1, graphile-build-pg@^4.0.0-beta.6:
version "4.0.0-rc.1"
resolved "https://registry.yarnpkg.com/graphile-build-pg/-/graphile-build-pg-4.0.0-rc.1.tgz#178b6389b5dfe8d1793d5a3f16ce5ca7bb567d98"
dependencies:
chalk "^2.1.0"
debug ">=2 <3"
graphile-build "4.0.0-beta.6"
graphile-build "4.0.0-rc.1"
graphql-iso-date "^3.2.0"
jsonwebtoken "^8.1.1"
lodash ">=4 <5"
lru-cache "4.1.1"
pg-sql2 "2.0.0"
pg-sql2 "2.1.0"
postgres-interval "1.1.1"

[email protected]beta.6:
version "4.0.0-beta.6"
resolved "https://registry.yarnpkg.com/graphile-build/-/graphile-build-4.0.0-beta.6.tgz#d3f15b16213c15728e72cfaa3adc733c690726a4"
[email protected]rc.1:
version "4.0.0-rc.1"
resolved "https://registry.yarnpkg.com/graphile-build/-/graphile-build-4.0.0-rc.1.tgz#c6037491498fd498b129c3b1053ced9d6cc5bd3f"
dependencies:
debug ">=2 <3"
graphql-parse-resolve-info "4.0.0-beta.6"
graphql-parse-resolve-info "4.0.0-rc.1"
lodash ">=4 <5"
pluralize "7.0.0"

graphql-iso-date@^3.2.0:
version "3.5.0"
resolved "https://registry.yarnpkg.com/graphql-iso-date/-/graphql-iso-date-3.5.0.tgz#55a1be0efa8d28c1453afd2eb5ce1d052189a513"

[email protected]beta.6:
version "4.0.0-beta.6"
resolved "https://registry.yarnpkg.com/graphql-parse-resolve-info/-/graphql-parse-resolve-info-4.0.0-beta.6.tgz#daa2e492617e5d6abde2ef0fb535403fcadecca0"
[email protected]rc.1:
version "4.0.0-rc.1"
resolved "https://registry.yarnpkg.com/graphql-parse-resolve-info/-/graphql-parse-resolve-info-4.0.0-rc.1.tgz#66ce65d4ef004000c69f2c34e2b10dc7aab74e6e"
dependencies:
debug ">=2 <3"

Expand Down Expand Up @@ -2410,9 +2410,9 @@ pg-pool@~2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/pg-pool/-/pg-pool-2.0.3.tgz#c022032c8949f312a4f91fb6409ce04076be3257"

pg-sql2@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/pg-sql2/-/pg-sql2-2.0.0.tgz#9b89c0fc31d99450f08777d5b3501e27f81d3d2e"
pg-sql2@2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/pg-sql2/-/pg-sql2-2.1.0.tgz#f86978278451482099e4f8e8db8b7486ecb67e3f"
dependencies:
debug ">=2 <3"

Expand Down Expand Up @@ -2465,12 +2465,12 @@ posix-character-classes@^0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab"

postgraphile-core@^4.0.0-beta.6:
version "4.0.0-beta.6"
resolved "https://registry.yarnpkg.com/postgraphile-core/-/postgraphile-core-4.0.0-beta.6.tgz#f7427ae22e2efd8b549d512603e1b075cc9321ab"
postgraphile-core@^4.0.0-beta.8:
version "4.0.0-rc.1"
resolved "https://registry.yarnpkg.com/postgraphile-core/-/postgraphile-core-4.0.0-rc.1.tgz#b980ae3e658acaee760d465cfe1b727a465a3027"
dependencies:
graphile-build "4.0.0-beta.6"
graphile-build-pg "4.0.0-beta.6"
graphile-build "4.0.0-rc.1"
graphile-build-pg "4.0.0-rc.1"

postgres-array@~1.0.0:
version "1.0.2"
Expand Down

0 comments on commit bad9425

Please sign in to comment.