diff --git a/.changeset/modern-sloths-pick.md b/.changeset/modern-sloths-pick.md new file mode 100644 index 0000000000..b9b4bb34f6 --- /dev/null +++ b/.changeset/modern-sloths-pick.md @@ -0,0 +1,10 @@ +--- +"graphile-build-pg": patch +"postgraphile": patch +--- + +PostGraphile will only throw an error when it fails to read enum table values +from a table in a published schema (one in the `schemas` list in your +pgServices); enum tables in other schemas will result in a warning instead +(since during the gather phase we don't know whether or not they will be needed +come schema build time). diff --git a/graphile-build/graphile-build-pg/src/plugins/PgEnumTablesPlugin.ts b/graphile-build/graphile-build-pg/src/plugins/PgEnumTablesPlugin.ts index fb41bcbe7b..9818688521 100644 --- a/graphile-build/graphile-build-pg/src/plugins/PgEnumTablesPlugin.ts +++ b/graphile-build/graphile-build-pg/src/plugins/PgEnumTablesPlugin.ts @@ -223,7 +223,7 @@ export const PgEnumTablesPlugin: GraphileConfig.Plugin = { * error caused by the statement above failing. */ } - throw new Error(`Introspection could not read from enum table "${ + const message = `Introspection could not read from enum table "${ pgClass.getNamespace()!.nspname }"."${pgClass.relname}", perhaps you need to grant access: GRANT USAGE ON SCHEMA "${pgClass.getNamespace()!.nspname}" TO "${role}"; @@ -231,7 +231,16 @@ export const PgEnumTablesPlugin: GraphileConfig.Plugin = { pgClass.relname }" TO "${role}"; Original error: ${e.message} -`); +`; + // Throw error if this enum table is in an exposed schema, otherwise just warn. + if ( + pgService?.schemas?.includes(pgClass.getNamespace()?.nspname ?? "") + ) { + throw new Error(message); + } else { + console.warn(message); + return []; + } } }, async processIntrospection(info, event) {