Documentation
¶
Overview ¶
Package hasura provides the single step-function entry point that wires Hasura metadata application into the nself lifecycle (start/deploy), so that `<project>/hasura/metadata/` on disk is never silently ignored.
Purpose: FIX-CLI-3 (P6 2026-09-04) — `nself build/start/deploy` never ran `hasura metadata apply`, so staging tracked 9 tables and prod 21 while the repo declared ~51 (46 np_/nself_/shopify_/idme_ tables never applied to either environment). This package closes that gap with one idempotent call. Inputs: a context, *config.Config, and the project directory. Outputs: an error only when metadata is present, apply fails, AND strict mode is on; otherwise a printed warning (dev default) or silent skip. Constraints: kept in its own package/file with a single call site in cmd/commands/start.go and the deploy paths, so it rebases cleanly against concurrent start*.go/internal/compose work tonight (coordination note, P6 crunch 2026-09-04).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyIfPresent ¶
ApplyIfPresent applies `<projectDir>/hasura/metadata/` to the running Hasura instance if that directory exists; otherwise it is a clean no-op.
Idempotent: safe to call on every start/deploy — Hasura's replace_metadata API is itself idempotent (CLI-R already relies on this for `nself db hasura metadata apply`).
Strictness: controlled by NSELF_HASURA_METADATA_STRICT (explicit override, "true"/"false"), else defaults to strict in staging/prod and warn-only in dev (cfg.Env). In warn mode a failed apply or inconsistency report prints but never fails the caller; in strict mode both fail it.
func IsStrict ¶
IsStrict reports whether metadata-apply failures should fail the caller, per NSELF_HASURA_METADATA_STRICT (explicit override) else cfg.Env (staging/prod = strict, dev = warn-only). Exported for reuse by the deploy paths, which need the same decision before deciding whether to fail a remote rolling restart.
Types ¶
This section is empty.