Skip to content

refactor: remove duplicative re-exports and options from graphql packages#764

Merged
pyramation merged 2 commits intomainfrom
devin/1772430816-cleanup-graphql-reexports
Mar 2, 2026
Merged

refactor: remove duplicative re-exports and options from graphql packages#764
pyramation merged 2 commits intomainfrom
devin/1772430816-cleanup-graphql-reexports

Conversation

@pyramation
Copy link
Copy Markdown
Contributor

@pyramation pyramation commented Mar 2, 2026

Summary

Eliminates duplicative type re-exports, redundant defaults, unused type guards, and dead legacy-detection code across graphql/server, graphql/types, and graphql/env. Consumers should import from OG sources (@pgpmjs/types, @pgpmjs/env, @constructive-io/graphql-types) instead of through convenience re-export layers.

Deleted:

  • graphql/server/src/options.ts — 298 lines of re-exported types, duplicate serverDefaults, unused type guards (isConstructiveOptions, hasPgConfig, hasServerConfig, hasApiConfig), dead isLegacyOptions/LEGACY_FIELDS, and redundant normalizeServerOptions

Removed re-exports:

  • graphql/types/src/index.ts: removed export * from '@pgpmjs/types'
  • graphql/env/src/index.ts: removed re-exports of @pgpmjs/env (loadConfigSync, getNodeEnv, etc.) and @constructive-io/graphql-types (ConstructiveOptions, constructiveDefaults, etc.)

Updated:

  • graphql/server/src/server.ts: replaced normalizeServerOptions(rawOpts) → getEnvOptions(normalized) with direct getEnvOptions(rawOpts)
  • Middleware imports: getNodeEnv now from @pgpmjs/env (OG source) instead of @constructive-io/graphql-env
  • graphql/server/package.json: added @pgpmjs/env as direct dependency

Updates since last revision

  • Restored a scoped ApiOptions type for the API middleware, but implemented as composition from OG sources (not a duplicated shape):
    • ApiOptions = PgpmOptions & { api?: ApiConfig } where ApiConfig is ApiOptions from @constructive-io/graphql-types
  • graphql/server/src/middleware/api.ts now correctly accepts ApiOptions (not ConstructiveOptions) to keep the middleware surface area minimal/semantic.

Review & Testing Checklist for Human

⚠️ Potential breaking changes — published packages may have external consumers.

  • Verify merge order equivalenceserver.ts now calls getEnvOptions(rawOpts) directly instead of normalizeServerOptions(rawOpts) → getEnvOptions(normalized). The old flow merged serverDefaults first, then passed to getEnvOptions. The new flow passes rawOpts directly and getEnvOptions applies constructiveDefaults internally. Values should be equivalent, but precedence changed slightly.
  • Confirm API middleware typing is right-sizedcreateApiMiddleware/getApiConfig/getSvcKey should only require pg + api config. Sanity-check any call sites that previously passed full ConstructiveOptions still type-check (they should, since ConstructiveOptions is compatible with PgpmOptions & { api?: ... } if its api type matches).
  • Check for external package consumers — removed re-exports may break downstream imports relying on @constructive-io/graphql-env/@constructive-io/graphql-types as “barrel” modules for pgpm exports.
  • Test GraphQL server startup & routing — start server locally (pnpm dev in graphql/server) and verify API resolution paths (services-disabled, domain lookup, X-Schemata / X-Api-Name headers) still behave as expected.

Notes

  • Local verification: pnpm build at repo root and pnpm test in graphql/server and graphql/env were run successfully during development.
  • pnpm-lock.yaml has a large diff due to install/lock formatting changes.

Session: https://app.devin.ai/sessions/0e3e61f1ce1340e7b5232ca2a687bcf5
Requested by: @pyramation


Open with Devin

…ages

- Delete graphql/server/src/options.ts (type re-exports, duplicate defaults, unused type guards, legacy detection)
- Remove export * from '@pgpmjs/types' in graphql/types/src/index.ts
- Remove all re-exports from graphql/env/src/index.ts (was re-exporting @pgpmjs/env and @constructive-io/graphql-types)
- Remove duplicate ApiOptions type from graphql/server/src/types.ts
- Replace normalizeServerOptions with direct getEnvOptions call in server.ts
- Update middleware imports: getNodeEnv from @pgpmjs/env, ApiOptions -> ConstructiveOptions
- Add @pgpmjs/env as direct dependency of graphql/server
@devin-ai-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@pyramation pyramation merged commit 687d71b into main Mar 2, 2026
44 checks passed
@pyramation pyramation deleted the devin/1772430816-cleanup-graphql-reexports branch March 2, 2026 22:01
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 5 additional findings.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant