Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/modern-sloths-pick.md
Original file line number Diff line number Diff line change
@@ -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).
13 changes: 11 additions & 2 deletions graphile-build/graphile-build-pg/src/plugins/PgEnumTablesPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,24 @@ 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}";
GRANT SELECT ON "${pgClass.getNamespace()!.nspname}"."${
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) {
Expand Down
Loading