Fix ObjectQL bridge class initialization and test infrastructure#382
Fix ObjectQL bridge class initialization and test infrastructure#382
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR addresses runtime/test failures caused by missing upstream ObjectQL methods during initialization and incomplete test mocks, and unblocks local dev startup by disabling a problematic Auth plugin configuration.
Changes:
- Refactors the
@objectql/corebridgeObjectQLso driver registration is deferred and overrides callsuper.*instead of compat recursion patterns. - Extends the
@objectstack/objectqlVitest/Jest-shim mock to include missing engine/registry methods used by tests. - Temporarily disables
AuthPluginin the rootobjectstack.config.tsdue to spec validation failures (camelCase vs snake_case).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| packages/foundation/core/src/app.ts | Defers driver registration to init() and switches overrides to super.* calls. |
| packages/foundation/core/test/mocks/@objectstack/objectql.ts | Adds missing mocked ObjectQL/SchemaRegistry APIs needed by the test suite. |
| objectstack.config.ts | Comments out AuthPlugin to avoid spec validation errors and allow dev server startup. |
Comments suppressed due to low confidence (1)
objectstack.config.ts:26
- Unused import AuthPlugin.
import { AuthPlugin } from '@objectstack/plugin-auth';
| // Temporarily disabled due to field naming validation errors (camelCase vs snake_case) | ||
| // The AuthPlugin uses camelCase field names (createdAt, updatedAt, emailVerified) | ||
| // which violate the ObjectQL spec requiring snake_case | ||
| // new AuthPlugin({ | ||
| // basePath: '/api/v1/auth' | ||
| // }), |
There was a problem hiding this comment.
AuthPlugin is commented out but still imported at the top of the file. With the repo’s ESLint config this will trigger a no-unused-vars warning; either remove the import while disabled or gate the plugin behind a flag so the import remains used when enabled.
| mockStore.set('object', new Map()); | ||
| } | ||
| const name = schema.name || 'unnamed'; | ||
| mockStore.get('object')!.set(name, schema); |
There was a problem hiding this comment.
SchemaRegistry.registerObject() ignores the packageId argument, but unregisterObjectsByPackage() later relies on obj.__packageId to remove objects. This makes package removal ineffective once objects have been registered. Persist the packageId on the stored schema (e.g., set __packageId) or track package→object mappings so unregisterObjectsByPackage can actually delete entries.
| mockStore.get('object')!.set(name, schema); | |
| const storedSchema = packageId ? { ...schema, __packageId: packageId } : schema; | |
| mockStore.get('object')!.set(name, storedSchema); |
| unregisterObjectsByPackage: jest.fn((packageId: string) => { | ||
| // In mock, just clear the objects store | ||
| const objects = mockStore.get('object'); | ||
| if (objects) { | ||
| const toDelete: string[] = []; | ||
| objects.forEach((obj, key) => { | ||
| if ((obj as any).__packageId === packageId) { | ||
| toDelete.push(key); | ||
| } |
There was a problem hiding this comment.
unregisterObjectsByPackage() will never delete anything because registerObject() never tags stored objects with the packageId (__packageId). Either tag on registration or implement removal based on a separate package index; otherwise ObjectQL.removePackage won’t behave like the real engine in tests.
| // Register any pending drivers from the constructor config | ||
| for (const { driver, isDefault } of this.pendingDrivers) { | ||
| (this as any).registerDriver(driver, isDefault); | ||
| } | ||
| this.pendingDrivers = []; |
There was a problem hiding this comment.
init() registers drivers via (this as any).registerDriver(...), which bypasses type-safety in a core class. Since the bridge already uses explicit declare for inherited APIs, consider declaring registerDriver (and registerHook if needed) on the class or extending UpstreamCompat so this call is typed and doesn’t rely on any.
Build passed but tests failed with "registerDriver/registerObject is not a function" errors. Dev server failed to start with field naming validation errors from AuthPlugin.
Changes
ObjectQL Bridge Class
File:
packages/foundation/core/src/app.tsDriver registration moved from constructor to
init()method. Parent class methods are not available during constructor execution.Method overrides use
supercalls instead of compat pattern to avoid infinite recursion.Test Mocks
File:
packages/foundation/core/test/__mocks__/@objectstack/objectql.tsExtended mock ObjectQL class with missing methods:
registerDriver(),registerObject(),getObject(),getConfigs()registerHook(),createContext(),removePackage(),init()Extended SchemaRegistry mock with:
registerObject(),getObject(),getAllObjects(),unregisterObjectsByPackage()Tests use mocks via vitest.config.ts aliases, not real implementations.
Dev Configuration
File:
objectstack.config.tsDisabled AuthPlugin - ships with camelCase field names (
createdAt,updatedAt,emailVerified) which fail snake_case validation. Upstream issue in @objectstack/plugin-auth@3.0.1.Status
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
fastdl.mongodb.org/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/objectql/objectql/node_modules/.bin/../vitest/vitest.mjs run sh -c tsc(dns block)fonts.googleapis.com/opt/hostedtoolcache/node/24.13.0/x64/bin/node /opt/hostedtoolcache/node/24.13.0/x64/bin/node /home/REDACTED/work/objectql/objectql/node_modules/.pnpm/next@16.1.6_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/next/dist/compiled/jest-worker/processChild.js(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Created from VS Code.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.