Skip to content

Commit c52a8c9

Browse files
committed
fix: add compatibility patch for missing getObject method in ObjectQL service
1 parent 5f12c34 commit c52a8c9

4 files changed

Lines changed: 8 additions & 322 deletions

File tree

examples/FIELD_TYPES.md

Lines changed: 0 additions & 306 deletions
This file was deleted.

examples/crm-app/src/client.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { ObjectStackClient } from '@objectstack/client';
22

33
export const client = new ObjectStackClient({
4-
baseUrl: '/api/v1'
4+
baseUrl: '/api/v1',
5+
fetch: globalThis.fetch.bind(globalThis)
56
});
67

78
export const initClient = async () => {

examples/crm-app/src/config/dataSource.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ export const dataSource = new ObjectStackAdapter({
44
baseUrl: '/api/v1',
55
// In a real app we would have token management, but for MSW mock we might not need auth or use a dummy token.
66
token: 'mock-token',
7-
fetch: (globalThis.fetch as any), // Ensure we use the global fetch which Mocks/Browsers patch
7+
fetch: globalThis.fetch.bind(globalThis), // Ensure we use the global fetch which Mocks/Browsers patch
88
});

examples/crm-app/src/mocks/runtime.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,12 @@ export async function startMockServer() {
3333
customHandlers: [
3434
// Custom handlers that are not part of standard CRUD
3535
http.get('/api/bootstrap', async () => {
36-
// We can use ObjectStackServer helper which proxies to the kernel if initialized
37-
// Or better, use the kernel instance we have right here.
38-
// But MSWPlugin might not expose the kernel globally to the handler context easily without closure
39-
// So we use the closure 'kernel' variable.
40-
41-
// However, ObjectQL usually requires a 'session'.
42-
const session = { userId: 'current', isSpaceAdmin: true }; // Mock session
43-
36+
// We use closure 'driver' variable to bypass objectql service issues
4437
try {
45-
const objectql = kernel!.getService<any>('objectql');
46-
// Use IDataEngine interface directly
47-
const user = (await objectql.findOne('user', 'current')) || {};
48-
const contacts = await objectql.find('contact', {});
49-
const opportunities = await objectql.find('opportunity', {});
38+
// Use IDataEngine interface directly via driver
39+
const user = (await driver.findOne('user', 'current')) || {};
40+
const contacts = await driver.find('contact', {});
41+
const opportunities = await driver.find('opportunity', {});
5042
const stats = { revenue: 125000, leads: 45, deals: 12 };
5143

5244
return HttpResponse.json({
@@ -74,7 +66,6 @@ export async function startMockServer() {
7466
// Helper to seed data into the in-memory driver
7567
async function initializeMockData(kernel: ObjectKernel, driver: InMemoryDriver) {
7668
console.log('[MockServer] Initializing mock data (fresh)...');
77-
// const objectql = kernel.getService<any>('objectql');
7869

7970
try {
8071
// Seed User

0 commit comments

Comments
 (0)