Skip to content

Commit

Permalink
feat(ignoreIndexes): add option hideIndexWarnings (#462)
Browse files Browse the repository at this point in the history
  • Loading branch information
tinymarsracing authored and benjie committed Aug 6, 2019
1 parent 254c80a commit 3cfb204
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/graphile-build-pg/src/plugins/PgBasicsPlugin.js
Expand Up @@ -138,7 +138,7 @@ const omitWithRBACChecks = omit => (
return omit(entity, permission);
};

const omitUnindexed = omit => (
const omitUnindexed = (omit, hideIndexWarnings) => (
entity: PgProc | PgClass | PgAttribute | PgConstraint,
permission: string
) => {
Expand All @@ -157,7 +157,9 @@ const omitUnindexed = omit => (
) {
let klass = entity.class;
if (klass) {
if (!entity._omitUnindexedReadWarningGiven) {
const shouldOutputWarning =
!entity._omitUnindexedReadWarningGiven && !hideIndexWarnings;
if (shouldOutputWarning) {
// $FlowFixMe
entity._omitUnindexedReadWarningGiven = true;
// eslint-disable-next-line no-console
Expand Down Expand Up @@ -324,6 +326,7 @@ export default (function PgBasicsPlugin(
pgColumnFilter = defaultPgColumnFilter,
pgIgnoreRBAC = false,
pgIgnoreIndexes = true, // TODO:v5: change this to false
pgHideIndexWarnings = false,
pgLegacyJsonUuid = false, // TODO:v5: remove this
}
) {
Expand All @@ -332,7 +335,7 @@ export default (function PgBasicsPlugin(
pgOmit = omitWithRBACChecks(pgOmit);
}
if (!pgIgnoreIndexes) {
pgOmit = omitUnindexed(pgOmit);
pgOmit = omitUnindexed(pgOmit, pgHideIndexWarnings);
}
builder.hook(
"build",
Expand Down
3 changes: 3 additions & 0 deletions packages/postgraphile-core/src/index.ts
Expand Up @@ -103,6 +103,7 @@ export interface PostGraphileCoreOptions {
ignoreRBAC?: boolean;
legacyFunctionsOnly?: boolean;
ignoreIndexes?: boolean;
hideIndexWarnings?: boolean;
subscriptions?: boolean;
live?: boolean;
ownerConnectionString?: string;
Expand Down Expand Up @@ -222,6 +223,7 @@ const getPostGraphileBuilder = async (
ignoreRBAC = true, // TODO:v5: Change to 'false' in v5
legacyFunctionsOnly = false, // TODO:v5: Remove in v5
ignoreIndexes = true, // TODO:v5: Change to 'false' in v5
hideIndexWarnings = false,
subscriptions: inSubscriptions = false, // TODO:v5: Change to 'true' in v5
live = false,
ownerConnectionString,
Expand Down Expand Up @@ -384,6 +386,7 @@ const getPostGraphileBuilder = async (
pgIgnoreRBAC: ignoreRBAC,
pgLegacyFunctionsOnly: legacyFunctionsOnly,
pgIgnoreIndexes: ignoreIndexes,
pgHideIndexWarnings: hideIndexWarnings,
pgOwnerConnectionString: ownerConnectionString,

/*
Expand Down

0 comments on commit 3cfb204

Please sign in to comment.