Skip to content

Commit

Permalink
fix(watch): fix startup crash when a non-superuser tries to watch (gr…
Browse files Browse the repository at this point in the history
…aphile#371)

* fix(watch): fix startup crash when non-superuser tries to watch

* Update watchPgSchemas.ts
  • Loading branch information
Michon van Dooren authored and calebmer committed Mar 5, 2017
1 parent 930b75b commit db16b50
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/postgraphql/watch/__tests__/watchPgSchemas-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ test('will log some stuff and continue if the watch fixtures query fails', async
await watchPgSchemas({ pgPool })
console.warn = origWarn
expect(pgPool.connect.mock.calls).toEqual([[]])
expect(pgClient.query.mock.calls).toEqual([[await _watchFixturesQuery], ['listen postgraphql_watch']])
expect(pgClient.query.mock.calls).toEqual([
[await _watchFixturesQuery],
['rollback'],
['listen postgraphql_watch'],
])
expect(pgClient.on.mock.calls.length).toBe(1)
expect(pgClient.on.mock.calls[0].length).toBe(2)
expect(pgClient.on.mock.calls[0][0]).toBe('notification')
Expand Down
1 change: 1 addition & 0 deletions src/postgraphql/watch/watchPgSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default async function watchPgSchemas ({ pgPool, pgSchemas, onChange }: {
console.warn(chalk.yellow('This is likely because your Postgres user is not a superuser. If the'))
console.warn(chalk.yellow('fixtures already exist, the watch functionality may still work.'))
// tslint:enable no-console
await pgClient.query('rollback')
}

// Listen to the `postgraphql_watch` channel. Any and all updates will come
Expand Down

0 comments on commit db16b50

Please sign in to comment.