Skip to content

Commit cdde8b8

Browse files
committed
Update usage for latest PostGraphile version
1 parent dbd8fa0 commit cdde8b8

3 files changed

Lines changed: 40 additions & 18 deletions

File tree

src/pages/postgraphile/usage-cli.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ postgraphile \
8888

8989
There are more CLI options available to customise the GraphQL server (these are
9090
from
91-
<tt>postgraphile@<!-- CLI_VERSION_BEGIN -->4.10.0<!-- CLI_VERSION_END --></tt>):
91+
<tt>postgraphile@<!-- CLI_VERSION_BEGIN -->4.12.3<!-- CLI_VERSION_END --></tt>):
9292

9393
<!-- prettier-ignore-start -->
9494
<!-- CLI_DOCBLOCK_BEGIN -->
@@ -104,7 +104,11 @@ from
104104
* `-s`, `--schema <string>`
105105
a Postgres schema to be introspected. Use commas to define multiple schemas
106106
* `-S`, `--subscriptions`
107-
Enable GraphQL websocket transport support for subscriptions (you still need a subscriptions plugin currently)
107+
Enable GraphQL support for subscriptions (you still need a subscriptions plugin currently)
108+
* `--websockets <string>`
109+
Choose which websocket transport libraries to use. Use commas to define multiple. Defaults to 'v0,v1' if `--subscriptions` or `--live` were passed, '[]' otherwise
110+
* `--websocket-operations <operations>`
111+
Toggle which GraphQL websocket transport operations are supported: 'subscriptions' or 'all'. Defaults to 'subscriptions'
108112
* `-L`, `--live`
109113
[EXPERIMENTAL] Enables live-query support via GraphQL subscriptions (sends updated payload any time nested collections/records change). Implies --subscriptions
110114
* `-w`, `--watch`

src/pages/postgraphile/usage-library.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ const postgraphileOptions = {
299299

300300
The `postgraphile` middleware factory function takes three arguments, all of
301301
which are optional. The below options are valid for
302-
<tt>postgraphile@<!-- LIBRARY_VERSION_BEGIN -->4.10.0<!-- LIBRARY_VERSION_END --></tt>.
302+
<tt>postgraphile@<!-- LIBRARY_VERSION_BEGIN -->4.12.3<!-- LIBRARY_VERSION_END --></tt>.
303303

304304
- **`pgConfig`**: An object or string that will be passed to the [`pg`][]
305305
library and used to connect to a PostgreSQL backend, OR a pg.Pool to use.
@@ -330,6 +330,11 @@ which are optional. The below options are valid for
330330
subscriptions (you still need a subscriptions plugin currently)
331331
- `live`: [EXPERIMENTAL] Enables live-query support via GraphQL subscriptions
332332
(sends updated payload any time nested collections/records change)
333+
- `websockets`: Choose which websocket transport libraries to use. Use commas
334+
to define multiple. Defaults to `['v0', 'v1']` if `subscriptions` or `live`
335+
are true, `[]` otherwise
336+
- `websocketOperations`: Toggle which GraphQL websocket transport operations
337+
are supported: 'subscriptions' or 'all'. Defaults to `subscriptions`
333338
- `websocketMiddlewares`: [EXPERIMENTAL] If you're using websockets
334339
(subscriptions || live) then you may want to authenticate your users using
335340
sessions or similar. You can pass some simple middlewares here that will be

src/pages/postgraphile/usage-schema.md

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ a GraphQLSchema object.
8787
The returned GraphQLSchema will **not** be updated when your database changes -
8888
if you require "watch" functionality, please use `watchPostGraphileSchema`
8989
instead (see below). The below options are valid for
90-
<tt>postgraphile@<!-- SCHEMA_VERSION_BEGIN -->4.10.0<!-- SCHEMA_VERSION_END --></tt>.
90+
<tt>postgraphile@<!-- SCHEMA_VERSION_BEGIN -->4.12.3<!-- SCHEMA_VERSION_END --></tt>.
9191

9292
- **`pgConfig`**: An object or string that will be passed to the [`pg`][]
9393
library and used to connect to a PostgreSQL backend. If you already have a
@@ -106,6 +106,11 @@ instead (see below). The below options are valid for
106106
subscriptions (you still need a subscriptions plugin currently)
107107
- `live`: [EXPERIMENTAL] Enables live-query support via GraphQL subscriptions
108108
(sends updated payload any time nested collections/records change)
109+
- `websockets`: Choose which websocket transport libraries to use. Use commas
110+
to define multiple. Defaults to `['v0', 'v1']` if `subscriptions` or `live`
111+
are true, `[]` otherwise
112+
- `websocketOperations`: Toggle which GraphQL websocket transport operations
113+
are supported: 'subscriptions' or 'all'. Defaults to `subscriptions`
109114
- `pgDefaultRole`: The default Postgres role to use. If no role was provided
110115
in a provided JWT token, this role will be used.
111116
- `dynamicJson`: By default, JSON and JSONB fields are presented as strings
@@ -176,8 +181,8 @@ instead (see below). The below options are valid for
176181

177182
### API: `watchPostGraphileSchema(pgConfig, schemaName, options, onNewSchema)`
178183

179-
This function takes the same options as `createPostGraphileSchema`; but with
180-
one addition: a function `onNewSchema` that is called every time a new schema is
184+
This function takes the same options as `createPostGraphileSchema`; but with one
185+
addition: a function `onNewSchema` that is called every time a new schema is
181186
generated, passing the new schema as the first argument. `onNewSchema` is
182187
guaranteed to be called before the `watchPostGraphileSchema` promise resolves.
183188
It resolves to an asynchronus function that can be called to stop listening for
@@ -245,18 +250,26 @@ look at the `postgraphile-core` and `graphile-build-pg` modules.
245250
You can issue GraphQL requests from various contexts, including within a
246251
resolver. To do so you need the following:
247252

248-
* Access to the `graphql` function from the `graphql` module
249-
* In a PostGraphile plugin, if you have access to the build object (which you usually will), you should get this from `build.graphql.graphql`
250-
* Failing that, you can `import { graphql } from 'graphql'` or `const { graphql } = require('graphql')`, but this has caveats.
251-
* A reference to the GraphQL schema object. You can get this from many sources:
252-
* in a resolver, you should extract it from `info.schema`
253-
* if you have access to the PostGraphile middleware, you can issue `await postgraphileMiddleware.getGqlSchema()`
254-
* if you don't need the PostGraphile middleware, you can use `await createPostGraphileSchema(...)` - see [schema only usage](/postgraphile/usage-schema/) - do this once and cache it because it's expensive to compute
255-
* A GraphQL operation (aka query, but includes mutations, subscriptions) to execute; this can be a string or an AST
256-
* The variables to feed to the operation (if necessary)
257-
* A valid GraphQL context for PostGraphile
258-
* inside a resolver, you can just pass the resolver's context straight through
259-
* in other situations, have a look at `withPostGraphileContext` in the [schema only usage](/postgraphile/usage-schema/)
253+
- Access to the `graphql` function from the `graphql` module
254+
- In a PostGraphile plugin, if you have access to the build object (which you
255+
usually will), you should get this from `build.graphql.graphql`
256+
- Failing that, you can `import { graphql } from 'graphql'` or
257+
`const { graphql } = require('graphql')`, but this has caveats.
258+
- A reference to the GraphQL schema object. You can get this from many sources:
259+
- in a resolver, you should extract it from `info.schema`
260+
- if you have access to the PostGraphile middleware, you can issue
261+
`await postgraphileMiddleware.getGqlSchema()`
262+
- if you don't need the PostGraphile middleware, you can use
263+
`await createPostGraphileSchema(...)` - see
264+
[schema only usage](/postgraphile/usage-schema/) - do this once and cache it
265+
because it's expensive to compute
266+
- A GraphQL operation (aka query, but includes mutations, subscriptions) to
267+
execute; this can be a string or an AST
268+
- The variables to feed to the operation (if necessary)
269+
- A valid GraphQL context for PostGraphile
270+
- inside a resolver, you can just pass the resolver's context straight through
271+
- in other situations, have a look at `withPostGraphileContext` in the
272+
[schema only usage](/postgraphile/usage-schema/)
260273

261274
Issuing a GraphQL operation from inside a resolver example:
262275

0 commit comments

Comments
 (0)