|
4 | 4 |
|
5 | 5 | Adds a powerful suite of filtering capabilities to a PostGraphile schema. |
6 | 6 |
|
7 | | -> **Warning:** Use of this plugin with the default options may make it **astoundingly trivial** for a malicious actor (or a well-intentioned application that generates complex GraphQL queries) to overwhelm your database with expensive queries. See the Performance and Security section below for details. |
8 | | -
|
9 | | -## Performance and Security |
10 | | - |
11 | | -By default, this plugin: |
12 | | - |
13 | | -- Exposes a large number of filter operators, including some that can perform expensive pattern matching. |
14 | | -- Allows filtering on [computed columns](https://www.graphile.org/postgraphile/computed-columns/), which can result in expensive operations. |
15 | | -- Allows filtering on functions that return `setof`, which can result in expensive operations. |
16 | | -- Allows filtering on List fields (Postgres arrays), which can result in expensive operations. |
17 | | - |
18 | | -To protect your server, you can: |
19 | | - |
20 | | -- Use the `connectionFilterAllowedFieldTypes` and `connectionFilterAllowedOperators` options to limit the filterable fields and operators exposed through GraphQL. |
21 | | -- Set `connectionFilterComputedColumns: false` to prevent filtering on [computed columns](https://www.graphile.org/postgraphile/computed-columns/). |
22 | | -- Set `connectionFilterSetofFunctions: false` to prevent filtering on functions that return `setof`. |
23 | | -- Set `connectionFilterArrays: false` to prevent filtering on List fields (Postgres arrays). |
24 | | - |
25 | | -Also see the [Production Considerations](https://www.graphile.org/postgraphile/production) page of the official PostGraphile docs, which discusses query whitelisting. |
| 7 | +> **Warning:** Use of this plugin with the default options may make it **astoundingly trivial** for a malicious actor (or a well-intentioned application that generates complex GraphQL queries) to overwhelm your database with expensive queries. See the [Performance and Security](https://github.com/graphile-contrib/postgraphile-plugin-connection-filter#performance-and-security) section below for details. |
26 | 8 |
|
27 | 9 | ## Usage |
28 | 10 |
|
@@ -51,6 +33,24 @@ const middleware = postgraphile(DATABASE_URL, SCHEMAS, { |
51 | 33 | }); |
52 | 34 | ``` |
53 | 35 |
|
| 36 | +## Performance and Security |
| 37 | + |
| 38 | +By default, this plugin: |
| 39 | + |
| 40 | +- Exposes a large number of filter operators, including some that can perform expensive pattern matching. |
| 41 | +- Allows filtering on [computed columns](https://www.graphile.org/postgraphile/computed-columns/), which can result in expensive operations. |
| 42 | +- Allows filtering on functions that return `setof`, which can result in expensive operations. |
| 43 | +- Allows filtering on List fields (Postgres arrays), which can result in expensive operations. |
| 44 | + |
| 45 | +To protect your server, you can: |
| 46 | + |
| 47 | +- Use the `connectionFilterAllowedFieldTypes` and `connectionFilterAllowedOperators` options to limit the filterable fields and operators exposed through GraphQL. |
| 48 | +- Set `connectionFilterComputedColumns: false` to prevent filtering on [computed columns](https://www.graphile.org/postgraphile/computed-columns/). |
| 49 | +- Set `connectionFilterSetofFunctions: false` to prevent filtering on functions that return `setof`. |
| 50 | +- Set `connectionFilterArrays: false` to prevent filtering on List fields (Postgres arrays). |
| 51 | + |
| 52 | +Also see the [Production Considerations](https://www.graphile.org/postgraphile/production) page of the official PostGraphile docs, which discusses query whitelisting. |
| 53 | + |
54 | 54 | ## Handling `null` and empty objects |
55 | 55 |
|
56 | 56 | By default, this plugin will throw an error when `null` literals or empty objects (`{}`) are included in `filter` input objects. This prevents queries with ambiguous semantics such as `filter: { field: null }` and `filter: { field: { equalTo: null } }` from returning unexpected results. For background on this decision, see https://github.com/graphile-contrib/postgraphile-plugin-connection-filter/issues/58. |
|
0 commit comments