Skip to content

Commit

Permalink
feat(watch): option to skip installing watch fixtures (#328)
Browse files Browse the repository at this point in the history
```js
const options = {
  graphileBuildOptions: {
    pgSkipInstallingWatchFixtures: true,
  }
};
```
  • Loading branch information
benjie committed Oct 27, 2018
1 parent 378bc2e commit e085cbd
Showing 1 changed file with 30 additions and 27 deletions.
57 changes: 30 additions & 27 deletions packages/graphile-build-pg/src/plugins/PgIntrospectionPlugin.js
Expand Up @@ -205,6 +205,7 @@ export default (async function PgIntrospectionPlugin(
pgThrowOnMissingSchema = false,
pgIncludeExtensionResources = false,
pgLegacyFunctionsOnly = false,
pgSkipInstallingWatchFixtures = false,
}
) {
async function introspect() {
Expand Down Expand Up @@ -593,33 +594,35 @@ export default (async function PgIntrospectionPlugin(
);
}
// Install the watch fixtures.
const watchSqlInner = await readFile(WATCH_FIXTURES_PATH, "utf8");
const sql = `begin; ${watchSqlInner}; commit;`;
try {
await pgClient.query(sql);
} catch (error) {
/* eslint-disable no-console */
console.warn(
`${chalk.bold.yellow(
"Failed to setup watch fixtures in Postgres database"
)} 锔忥笍鈿狅笍`
);
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."
)
);
console.warn(
chalk.yellow("Enable DEBUG='graphile-build-pg' to see the error")
);
debug(error);
/* eslint-enable no-console */
await pgClient.query("rollback");
if (!pgSkipInstallingWatchFixtures) {
const watchSqlInner = await readFile(WATCH_FIXTURES_PATH, "utf8");
const sql = `begin; ${watchSqlInner}; commit;`;
try {
await pgClient.query(sql);
} catch (error) {
/* eslint-disable no-console */
console.warn(
`${chalk.bold.yellow(
"Failed to setup watch fixtures in Postgres database"
)} 锔忥笍鈿狅笍`
);
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."
)
);
console.warn(
chalk.yellow("Enable DEBUG='graphile-build-pg' to see the error")
);
debug(error);
/* eslint-enable no-console */
await pgClient.query("rollback");
}
}

await pgClient.query("listen postgraphile_watch");
Expand Down

0 comments on commit e085cbd

Please sign in to comment.