Skip to content

Modernize GraphQLComponent: bug fixes, type safety, hardening, and docs (v6.1.0) #116

Open
tlivings wants to merge 5 commits intoExpediaGroup:masterfrom
tlivings:master
Open

Modernize GraphQLComponent: bug fixes, type safety, hardening, and docs (v6.1.0) #116
tlivings wants to merge 5 commits intoExpediaGroup:masterfrom
tlivings:master

Conversation

@tlivings
Copy link
Copy Markdown
Collaborator

Summary

  • 7 bug fixes: falsy transform values, federation schema invalidation, context dispose checks, circular stableStringify,
    empty data source names, namespace shadowing prevention, and missing import injector defaults
  • Type safety & modernization: enable noImplicitAny, add private modifiers, dispose guards on all public getters, proper
    nullable types, middleware/config validation
  • Behavioral improvements: memoize only Query resolvers (not Mutation), context.use() returns unsubscribe function,
    middleware array snapshot prevents mutation during iteration, circular self-import detection, cached Proxy method wrappers for
    reduced GC pressure
  • 30 new tests covering middleware errors, namespace collisions, subscription binding, concurrent context, falsy transforms,
    federation invalidation, circular imports, and more (all 156 tests passing)
  • Code style cleanup: remove prettier, fix formatting violations, align with project style guide
  • New context-middleware example demonstrating auth, logging, and namespace composition patterns
  • README rewrite and version bump to 6.1.0

Test plan

  • npm test — all 156 tests pass
  • npm run build — clean TypeScript compilation

tlivings and others added 5 commits March 30, 2026 16:32
…mprovements, and cleanup

- Add private modifiers and proper nullable types for _schema/_transformedSchema
- Add disposed state tracking with _assertNotDisposed guards on all public getters
- Stop mutating imported components' federation flag (breaking behavioral fix)
- Change context.use() to return unsubscribe function instead of chaining
- Add middleware validation, context/transforms config validation
- Memoize only Query resolvers (not Mutation) to prevent stale mutation results
- Cache imported component data source injectors to avoid per-request recreation
- Replace destructive while/shift with for-of in transformSchema
- Add invalidateSchema() for schema rebuild support
- Enable noImplicitAny, add type annotations throughout src and tests
- Add new test files for dispose, error handling, schema invalidation
- Fix prepublish -> prepublishOnly, add prettier/husky config, sort devDeps

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Round 1 fixes (all 156 tests passing):
- Fix TS compilation error in stitchSchemas resolver cast
- Fix undefined types wrapping to [] instead of [undefined]
- Consolidate dual context-building paths into single flow
- Add data source name collision warnings
- Add typeof guard on Query resolvers in bindResolvers
- Stable memoization cache key with sorted keys
- Cache Proxy method wrappers to reduce GC pressure
- Simplify mocks condition check
- Skip mergeTypeDefs for single non-federation type

Project setup:
- Add AGENTS.md with project-specific agent instructions
- Add CLAUDE.md symlink to AGENTS.md
- Remove .cursor/rules/ (content extracted to AGENTS.md)
- Add .continue-here.md with 16 remaining hardening items

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Bugs fixed:
- Transform loop no longer breaks on falsy (null/0/false) return values
- Federation setter now invalidates cached schema
- Context function checks dispose state on each call
- stableStringify handles circular references via try/catch fallback
- Data source empty string name no longer falls through to constructor name
- Namespace 'dataSources' rejected in validation to prevent shadow
- Import injector defaults to [] when component omits dataSources

Hardening:
- Circular self-import detection in constructor
- Middleware array snapshot before iteration prevents mutation during loop
- Added "types" and "exports" fields to package.json

Tests: middleware errors, namespace collision, subscription binding,
middleware unsubscribe, concurrent context calls, custom IGraphQLComponent
without dataSources, falsy transforms, federation invalidation, circular
import guard, stableStringify with contextValue.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove prettier: devDependency, format script, .prettierrc, .npmignore entry
- Fix else/catch placement to new line (4 occurrences)
- Add missing semicolons on type definitions and statements (7 occurrences)
- Remove trailing whitespace (4 occurrences)
- Fix double space in class declaration
- Convert arrow functions to function declarations where this is not needed
- Update AGENTS.md: remove prettier reference, update function style rule
- Remove .continue-here.md

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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