Skip to content

Commit 3cfb204

Browse files
tinymarsracingbenjie
authored andcommitted
feat(ignoreIndexes): add option hideIndexWarnings (#462)
1 parent 254c80a commit 3cfb204

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ const omitWithRBACChecks = omit => (
138138
return omit(entity, permission);
139139
};
140140

141-
const omitUnindexed = omit => (
141+
const omitUnindexed = (omit, hideIndexWarnings) => (
142142
entity: PgProc | PgClass | PgAttribute | PgConstraint,
143143
permission: string
144144
) => {
@@ -157,7 +157,9 @@ const omitUnindexed = omit => (
157157
) {
158158
let klass = entity.class;
159159
if (klass) {
160-
if (!entity._omitUnindexedReadWarningGiven) {
160+
const shouldOutputWarning =
161+
!entity._omitUnindexedReadWarningGiven && !hideIndexWarnings;
162+
if (shouldOutputWarning) {
161163
// $FlowFixMe
162164
entity._omitUnindexedReadWarningGiven = true;
163165
// eslint-disable-next-line no-console
@@ -324,6 +326,7 @@ export default (function PgBasicsPlugin(
324326
pgColumnFilter = defaultPgColumnFilter,
325327
pgIgnoreRBAC = false,
326328
pgIgnoreIndexes = true, // TODO:v5: change this to false
329+
pgHideIndexWarnings = false,
327330
pgLegacyJsonUuid = false, // TODO:v5: remove this
328331
}
329332
) {
@@ -332,7 +335,7 @@ export default (function PgBasicsPlugin(
332335
pgOmit = omitWithRBACChecks(pgOmit);
333336
}
334337
if (!pgIgnoreIndexes) {
335-
pgOmit = omitUnindexed(pgOmit);
338+
pgOmit = omitUnindexed(pgOmit, pgHideIndexWarnings);
336339
}
337340
builder.hook(
338341
"build",

packages/postgraphile-core/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ export interface PostGraphileCoreOptions {
103103
ignoreRBAC?: boolean;
104104
legacyFunctionsOnly?: boolean;
105105
ignoreIndexes?: boolean;
106+
hideIndexWarnings?: boolean;
106107
subscriptions?: boolean;
107108
live?: boolean;
108109
ownerConnectionString?: string;
@@ -222,6 +223,7 @@ const getPostGraphileBuilder = async (
222223
ignoreRBAC = true, // TODO:v5: Change to 'false' in v5
223224
legacyFunctionsOnly = false, // TODO:v5: Remove in v5
224225
ignoreIndexes = true, // TODO:v5: Change to 'false' in v5
226+
hideIndexWarnings = false,
225227
subscriptions: inSubscriptions = false, // TODO:v5: Change to 'true' in v5
226228
live = false,
227229
ownerConnectionString,
@@ -384,6 +386,7 @@ const getPostGraphileBuilder = async (
384386
pgIgnoreRBAC: ignoreRBAC,
385387
pgLegacyFunctionsOnly: legacyFunctionsOnly,
386388
pgIgnoreIndexes: ignoreIndexes,
389+
pgHideIndexWarnings: hideIndexWarnings,
387390
pgOwnerConnectionString: ownerConnectionString,
388391

389392
/*

0 commit comments

Comments
 (0)