Skip to content

Commit e085cbd

Browse files
authored
feat(watch): option to skip installing watch fixtures (#328)
```js const options = { graphileBuildOptions: { pgSkipInstallingWatchFixtures: true, } }; ```
1 parent 378bc2e commit e085cbd

File tree

1 file changed

+30
-27
lines changed

1 file changed

+30
-27
lines changed

packages/graphile-build-pg/src/plugins/PgIntrospectionPlugin.js

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ export default (async function PgIntrospectionPlugin(
205205
pgThrowOnMissingSchema = false,
206206
pgIncludeExtensionResources = false,
207207
pgLegacyFunctionsOnly = false,
208+
pgSkipInstallingWatchFixtures = false,
208209
}
209210
) {
210211
async function introspect() {
@@ -593,33 +594,35 @@ export default (async function PgIntrospectionPlugin(
593594
);
594595
}
595596
// Install the watch fixtures.
596-
const watchSqlInner = await readFile(WATCH_FIXTURES_PATH, "utf8");
597-
const sql = `begin; ${watchSqlInner}; commit;`;
598-
try {
599-
await pgClient.query(sql);
600-
} catch (error) {
601-
/* eslint-disable no-console */
602-
console.warn(
603-
`${chalk.bold.yellow(
604-
"Failed to setup watch fixtures in Postgres database"
605-
)} ️️⚠️`
606-
);
607-
console.warn(
608-
chalk.yellow(
609-
"This is likely because your Postgres user is not a superuser. If the"
610-
)
611-
);
612-
console.warn(
613-
chalk.yellow(
614-
"fixtures already exist, the watch functionality may still work."
615-
)
616-
);
617-
console.warn(
618-
chalk.yellow("Enable DEBUG='graphile-build-pg' to see the error")
619-
);
620-
debug(error);
621-
/* eslint-enable no-console */
622-
await pgClient.query("rollback");
597+
if (!pgSkipInstallingWatchFixtures) {
598+
const watchSqlInner = await readFile(WATCH_FIXTURES_PATH, "utf8");
599+
const sql = `begin; ${watchSqlInner}; commit;`;
600+
try {
601+
await pgClient.query(sql);
602+
} catch (error) {
603+
/* eslint-disable no-console */
604+
console.warn(
605+
`${chalk.bold.yellow(
606+
"Failed to setup watch fixtures in Postgres database"
607+
)} ️️⚠️`
608+
);
609+
console.warn(
610+
chalk.yellow(
611+
"This is likely because your Postgres user is not a superuser. If the"
612+
)
613+
);
614+
console.warn(
615+
chalk.yellow(
616+
"fixtures already exist, the watch functionality may still work."
617+
)
618+
);
619+
console.warn(
620+
chalk.yellow("Enable DEBUG='graphile-build-pg' to see the error")
621+
);
622+
debug(error);
623+
/* eslint-enable no-console */
624+
await pgClient.query("rollback");
625+
}
623626
}
624627

625628
await pgClient.query("listen postgraphile_watch");

0 commit comments

Comments
 (0)