npm install @objectstack/runtimeimport { ObjectStackKernel, ObjectQLPlugin } from '@objectstack/runtime';
const kernel = new ObjectStackKernel([
new ObjectQLPlugin(),
// ... other plugins
]);
await kernel.start();import { ObjectStackKernel, ObjectQLPlugin, ObjectQL } from '@objectstack/runtime';
// Create custom instance
const customQL = new ObjectQL({
env: 'production',
// custom options
});
// Configure as needed
customQL.registerHook('beforeInsert', async (ctx) => {
console.log(`Inserting into ${ctx.object}`);
});
// Use in kernel
const kernel = new ObjectStackKernel([
new ObjectQLPlugin(customQL),
// ... other plugins
]);
await kernel.start();// Still works without ObjectQLPlugin, but shows warning
const kernel = new ObjectStackKernel([
// ... plugins
]);new ObjectQLPlugin(ql?: ObjectQL, hostContext?: Record<string, any>)Parameters:
ql(optional): Custom ObjectQL instance to usehostContext(optional): Configuration for new ObjectQL instance (ignored ifqlprovided)
Note: If both parameters are provided, hostContext is ignored with a warning.
// Create with default settings
new ObjectQLPlugin()
// Use custom instance
const custom = new ObjectQL({ env: 'prod' });
new ObjectQLPlugin(custom)
// Create with custom context
new ObjectQLPlugin(undefined, { env: 'prod', debug: true })Before:
const kernel = new ObjectStackKernel([appConfig, driver]);After:
const kernel = new ObjectStackKernel([
new ObjectQLPlugin(), // Add this line
appConfig,
driver
]);import { ObjectQLPlugin } from '@objectstack/runtime';
import { MockObjectQL } from './mocks';
const mockQL = new MockObjectQL();
const kernel = new ObjectStackKernel([
new ObjectQLPlugin(mockQL),
// ... test config
]);// Production
const prodQL = new ObjectQL({ env: 'production', cache: true });
const prodKernel = new ObjectStackKernel([
new ObjectQLPlugin(prodQL),
// ... production plugins
]);
// Development
const devKernel = new ObjectStackKernel([
new ObjectQLPlugin(undefined, { env: 'development', debug: true }),
// ... dev plugins
]);// Your custom implementation
import { MyCustomObjectQL } from '@mycompany/custom-objectql';
const customQL = new MyCustomObjectQL({
specialFeature: true,
// custom options
});
const kernel = new ObjectStackKernel([
new ObjectQLPlugin(customQL),
// ... other plugins
]);This means the kernel tried to use ObjectQL before it was set up. Make sure:
- You include
ObjectQLPluginin your plugins array, OR - The kernel has backward compatibility enabled
This is a deprecation warning. Your code will work, but consider migrating to:
new ObjectStackKernel([
new ObjectQLPlugin(), // Add this
// ... other plugins
]);You passed both a custom ObjectQL instance and host context:
// ❌ Don't do this
new ObjectQLPlugin(customQL, { env: 'prod' }) // hostContext ignored
// ✅ Do this instead
new ObjectQLPlugin(customQL) // Use custom instance
// ✅ Or this
new ObjectQLPlugin(undefined, { env: 'prod' }) // Create with contextObjectQLPlugin uses a symbol for reliable detection:
import { OBJECTQL_PLUGIN_MARKER } from '@objectstack/runtime';
// Check if a plugin is an ObjectQL plugin
const isObjectQLPlugin = OBJECTQL_PLUGIN_MARKER in plugin;The kernel's ql property is typed as optional:
export class ObjectStackKernel {
public ql?: ObjectQL;
private ensureObjectQL(): ObjectQL {
if (!this.ql) {
throw new Error('ObjectQL engine not initialized');
}
return this.ql;
}
}Apache-2.0