1.0.4 • Published 3 years ago
@graphile/pro v1.0.4
@graphile/pro
This is a PostGraphile plugin that includes a number of optional protections for your production server. Unlike PostGraphile, this plugin is NOT open source software - see "License key" lower down.
Current protections:
- Force pagination caps (require user to supply a 'first' or 'last' argument to collections, customise or disable per table via
@paginationCap
smart comment) - Scale by sending queries to read replicas
- Limiting GraphQL query depth
- GraphQL cost limit (experimental! Estimates the cost of a GraphQL query before sending it to the database, aborts if it looks too expensive. Good production protection, but also great during development to ensure you've thought carefully about the queries you're building, helping you make faster applications.)
To read about these protections, see:
https://www.graphile.org/postgraphile/production/
Usage
CLI:
yarn add postgraphile @graphile/pro
export GRAPHILE_LICENSE="MY_LICENSE_KEY_HERE"
yarn postgraphile --plugins @graphile/pro
Library:
Assuming you have server.js
something like:
// server.js
const http = require("http");
const { postgraphile, makePluginHook } = require("postgraphile");
const pluginHook = makePluginHook([require("@graphile/pro").default]);
http
.createServer(
postgraphile(process.env.DATABASE_URL, "public", {
pluginHook,
})
)
.listen(5000);
Install and run:
yarn add postgraphile @graphile/pro
export GRAPHILE_LICENSE="MY_LICENSE_KEY_HERE"
node server.js
License key
You must specify the license key in an environmental variable
GRAPHILE_LICENSE
. You can acquire the license key from
https://store.graphile.com
If you fail to provide the license key, then the module will throw an error.