Skip to content

Commit e01c6b8

Browse files
committed
feat: enhance metadata service methods for improved object retrieval and handling of missing parameters
1 parent 1daacbf commit e01c6b8

1 file changed

Lines changed: 22 additions & 4 deletions

File tree

examples/app-react-crud/src/mocks/createKernel.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,32 @@ export async function createKernel(options: KernelOptions) {
182182

183183
if (service === 'metadata') {
184184
if (method === 'objects') {
185-
let objs = ql && ql.getObjects ? ql.getObjects() : [];
186-
if (objs.length === 0) {
185+
// Try engine first if implemented
186+
let objs = (ql && typeof ql.getObjects === 'function') ? ql.getObjects() : [];
187+
188+
if (!objs || objs.length === 0) {
187189
objs = SchemaRegistry.getAllObjects();
188190
}
189191
return objs;
190192
}
191-
if (method === 'getObject') {
192-
return SchemaRegistry.getObject(params.objectName) || (ql ? ql.getObject(params.objectName) : null);
193+
if (method === 'getObject' || method === 'getItem') {
194+
// Hack: If no objectName provided, it might be a list request mapped incorrectly
195+
// or a request for the "object" type definition itself?
196+
// For 'object', we usually want the list if no name.
197+
if (!params.objectName && !params.name) {
198+
return SchemaRegistry.getAllObjects();
199+
}
200+
201+
const name = params.objectName || params.name;
202+
203+
// Check registry first (synchronous cache)
204+
let def = SchemaRegistry.getObject(name);
205+
206+
// If not found, try engine (might be dynamic)
207+
if (!def && ql && typeof (ql as any).getObject === 'function') {
208+
def = (ql as any).getObject(name);
209+
}
210+
return def || null;
193211
}
194212
}
195213

0 commit comments

Comments
 (0)