aws / aws/graph-explorer

Config file loader with Zod schema and env var overrides

Open
#1,661 0 comments 0 reactions 0 assignees View on GitHub
enhancement fundamental infrastructure
Dominant language
TypeScript
Stars
481
Forks
108
Avg merge
8d 9h
Merged PRs (30d)
7

Description

## Parent PRD

#1660

## What to build

Implement the core config file loading mechanism for Graph Explorer. The server reads `GE_CONFIG` env var (defaulting to `./graph-explorer.config.json`), parses the JSON, and validates it with a Zod schema. When no file is found, the server starts with empty defaults (no connections). `GE_*` environment variables (`GE_PORT`, `GE_LOG_LEVEL`, `GE_LOG_FORMAT`, `GE_TLS`, `GE_TLS_CERT`, `GE_TLS_KEY`) override their corresponding config file values.

The Zod schema should cover the full config shape defined in #1660: `server` block (port, logLevel, logFormat, tls, corsOrigin), `connections` (keyed by stable ID, with name, url, queryEngine, fetchTimeout, nodeExpansionLimit, authentication as a discriminated union), and `feedbackUrl`. All fields optional with sensible defaults.

This replaces the current `env.ts` validation, `dotenv` loading, and `CONFIGURATION_FOLDER_PATH` logic.

## Acceptance criteria

- [ ] Reads config from `GE_CONFIG` env var path, falls back to `./graph-explorer.config.json`
- [ ] Parses and validates JSON with Zod schema matching the shape in #1660
- [ ] Starts with empty defaults when no config file is found (no error)
- [ ] Logs a clear error and exits when config file exists but is malformed
- [ ] `GE_PORT`, `GE_LOG_LEVEL`, `GE_LOG_FORMAT`, `GE_TLS`, `GE_TLS_CERT`, `GE_TLS_KEY` override config file values
- [ ] Unit tests for: valid config, missing file, malformed file, env var overrides, partial config

## Blocked by

None - can start immediately

## User stories addressed

- User story 1
- User story 4
- User story 5
- User story 11
- User story 13

Contributor guide

Open the contributing guide

Research direction

Start by reading the current env.ts validation, dotenv loading, and CONFIGURATION_FOLDER_PATH logic, then compare the required config shape with parent issue #1660. Add unit tests for valid, missing, malformed, overridden, and partial configurations; done means the listed acceptance criteria pass, including clear failure on malformed files and empty defaults when files are absent.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.