Scan your whole stack
From OX Research Newsroom
Are you using @graphile-contrib/view-constraints?
Find out what’s in your code.
Scan your apps free in minutes (opens in a new tab)Latest version: v0.11.0
@graphile-contrib/view-constraints was last scanned on 30 Nov 2026 at version 0.11.0. Risk score 0 of 100. No malicious behavior was detected.
| Version | Published | Status |
|---|---|---|
| 0.11.0 LATEST | 30 Nov 2026 | No rules fired |
| 0.10.0 | 29 Nov 2026 | No rules fired |
| 0.9.0 | 27 Nov 2026 | No rules fired |
| 0.8.0 | 16 Nov 2026 | Not shown |
| 0.7.1 | 5 Nov 2026 | Not shown |
Findings for v0.11.0. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.
The score describes 0.11.0; other versions have their own rules, not their own score.
The publisher’s own README, as collected from the registry.
An opt-in PostGraphile v5 plugin that derives a view's foreign keys, primary key, and non-null columns from PostgreSQL's query plan and system catalogs.
npm install @graphile-contrib/view-constraints
import { PgViewConstraintsPlugin } from '@graphile-contrib/view-constraints'
export default {
plugins: [PgViewConstraintsPlugin()]
}
The plugin runs before PgFakeConstraintsPlugin, which turns the derived tags
into relations in the generated schema.
Pass declare: false only to inspect a report without changing the schema: a schema in
which something stands on a derived key — a relational @interface whose variant is a
view, say — is not built without the tags that declare it. Pass indexes: true to derive
which view columns are backed by an index (see "Index-backed columns").
A view's @primaryKey is a set of its columns that no two rows share and that is
never NULL (PgFakeConstraintsPlugin makes every key column non-null). Keys are
worked out bottom-up over the plan:
| Node | Its unique column sets |
|---|---|
| a relation scan | its primary key and unique indexes (pg_index; not partial, expression or deferrable ones) |
| a block of inner joins | a key of each of the fewest row sources whose rows determine every other source's through the column = column / column = literal equalities the plan prints |
a Left / Right join |
the preserved side's keys where it determines the other side |
a Semi / Anti join |
the keys of the side it emits |
Aggregate / Group with a Group Key of columns, Unique |
the group key or every column, and the input's keys it contains |
a UNION ALL |
a key of every branch plus a column each branch fills with its own non-NULL text literal |
| anything else | none |
Below a join, what a grouping, a de-duplication, a LIMIT or a window makes unique
is only used to show the join does not multiply rows: whether the planner keeps a
Subquery Scan over such a subquery depends on the join method. A key is never
read across a cast. Only a key that is one base relation's own can be the target
of a relation to a projection.
The reader keeps at most 64 keys per node and assembles a key from at most 4 relations
(KEYS_PER_NODE, RELATIONS_PER_KEY in plan-keys.ts). Both are caps on how much work
one plan may be asked for, not on what is true: a key beyond them is missed, never
claimed. A view whose rows are told apart only by a wider key, or by more relations
together, is left without a derived @primaryKey or @unique, and the plan proves
nothing false.
Where the plan proves a set of the view's columns no two rows share but that set is
not also never-NULL, the view carries a @unique tag rather than a @primaryKey.
The key is the same reading of the plan — a base relation's unique index or primary
key carried without a multiplying join, a group key, a DISTINCT — and a
@unique is what declares it where a key column may be NULL: PgFakeConstraintsPlugin
makes a @primaryKey column non-null and leaves a @unique column as it is, and
PostgreSQL's own uniqueness admits a NULL beside anything (a UNIQUE index admits
any number of NULLs), so declaring a nullable key is sound where declaring it
non-null would not be. A key an outer join can null is no row identity for either tag
— the padded rows carry the same NULL, which tells none of them apart — so the same
guard a @primaryKey is taken under yields neither, and the plan's own set is named
in the view's notes. A key holding a column whose plan reading was refused — one read
from a WITH query a plan may spell either way — yields neither either: whether that
column is never NULL is what the plan cannot say. Of the keys it derives, a view
gets the @primaryKey or the
@unique and never both: a key whose every column is never NULL is the @primaryKey
of "Row identity", and only where no such key exists does the @unique stand. This is
the derived pair alone. A hand-written @primaryKey the derivation does not match is
left where it is, and a derived @unique may stand beside it — a table carries a
primary key and a unique constraint at once, and the two say different things. Pass
deriveUnique: false to PgViewConstraintsPlugin to leave @unique underived, for
instance to keep the generated schema's row-lookup fields to the primary keys alone.
Where a published view is a row of a base relation — its @primaryKey is that
relation's own unique key, carried — a relation to that key is led to the view too,
beside the relation to the table. The referencing half is either a relation derived
for a view, or a real convalidated foreign key of a table of the same surface (a
table in one of the service's schemas some column of which the role may read). The
relation is nullable.
Exactly one view of the surface may be a row of the key: with several, nothing is
led and the view or table names the refusal more-than-one-projection-carries-the-key
and the candidates. A view published as an @enum, and one whose hand-written
@primaryKey names other columns, is no candidate. A view is not led to its own row
over the very columns it carries. A table's foreign key itself is left to
PgRelationsPlugin; only the relation to the projection is declared, and not where
the table already states the same reference by hand.
A relation of a plain view led from real foreign keys says which: its @foreignKey
carries |@backedBy <schema>.<table>.<constraint>, one name per branch read
(a UNION's), sorted.
@foreignKey (cur_code) references lab.currency (code)|@backedBy lab.tx.tx_cur_code_fkey
The keys named there are what guarantees the target row exists for every view row
whose key columns are not NULL: the view column carries the base column's value, and
the base column's key holds that row to its target. A reader that wants to know — for
instance whether the relation can be published non-null — re-reads the named
constraints in pg_constraint (validated, enforced, not deferrable); the tag says
where to look and claims nothing on its own. PostGraphile itself ignores it.
No @backedBy is written where a branch is authorised by anything but a foreign key to
the same target — a carried primary key, whose relation is the base row's own identity,
or a relation to a projection — nor on a materialized view, whose stored row outlives
the row its key referenced. A hand-written @foreignKey for a reference this plugin
derives is not declared a second time; it gains the |@backedBy the derivation found,
unless it states one of its own, and is otherwise left as written.
A relation is led from where a column's value comes from, read once — the plan's reading,
shared with non-nullness, keys and index backing, and where the plan leaves a column unread,
the view's stored tree — and nothing a row filter does changes that value: a join, an
EXISTS or a NOT EXISTS drops rows and keeps the column the base column's proxy. A
UNION ALL is led where every branch authorises the same target, a GROUP BY key is the
column it groups by, and a column read from a grouping WITH query or subquery the plan may
print either way (see "Non-nullness") is traced by the stored tree through every plain view
on the way to the base table, each view by its own tree. The trace takes only a bare column
reference: an expression, an aggregate, a set operation's column, and an outer join's merged
USING column — a COALESCE of both sides, either of which may hold a value the target does
not — end it with nothing, and the column's own refusal (not-a-column-reference, …) names
that. The nulled side of an outer join passes, because a foreign key allows NULL.
A column that reaches a relation and is still led to no key of it says why in
ViewDerivation.relationRefusals (RELATION_REFUSALS), in the view's notes, and in the
report's census:
| Refusal | The column |
|---|---|
union-branches-share-no-key |
is a union's column whose branches proxy base columns that carry keys, but no target every branch authorises — UNION ALL over two different targets |
through-a-materialized-view |
is read from a materialized view, which carries no key and whose stored row outlives the row its source's key referenced; the trace never crosses one |
through-an-unfollowed-view |
was left unread by the plan and traced by the stored tree to a view whose own tree traces it no further: its column is an expression, or its tree was not read |
A column whose base column carries no key has nothing to prove and names no refusal.
A column is @notNull when it proxies a base column that is never NULL where it
is read — attnotnull, or a qualifier of the plan rejects the NULL: a conjunct
column IS NOT NULL, or column = … through a strict operator (read only while
every = in the database is strict) — and no outer join, NULL union branch or
GROUPING SETS row puts a NULL in. A materialized view is read by the same rule: its
stored copy of an entry that was never NULL holds no NULL either, so the column its
key is taken from carries @notNull beside the key rather than the key alone. A
qualifier counts only where it holds of
every row the column arrives in: not an outer or anti join's own condition, not a
disjunction's arm, not a subplan. The predicate of a partial index a scan names is
read as a qualifier of that scan, since the scan drops what the predicate implies
from its Filter.
A column the select list spells as an expression has no base column to ask, and
what it has instead is the expression's own shape. The Output entry the origins
are read from is parsed and evaluated bottom-up, and a shape whose SQL definition
is the claim proves the column never NULL:
Find threats in your stack.
OX Radar can check high-priority threats, like critical package CVEs, against your context.
Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.
The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).
The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.