This guide explains how to integrate Object UI with ObjectQL API backends to create data-driven applications.
ObjectQL is a metadata-driven backend platform that provides automatic CRUD APIs based on object definitions. The @object-ui/data-objectql package provides a seamless bridge between Object UI components and ObjectQL APIs.
┌─────────────────────────────────────────────────────────────┐
│ Object UI Components │
│ (Forms, Tables, Cards, Dashboards, etc.) │
└──────────────────┬──────────────────────────────────────────┘
│
│ Uses DataSource Interface
│
┌──────────────────▼──────────────────────────────────────────┐
│ @object-ui/data-objectql │
│ │
│ • ObjectQLDataSource (API Adapter) │
│ • React Hooks (useObjectQL, useObjectQLQuery, etc.) │
│ • Query Parameter Conversion │
│ • Error Handling & Type Safety │
└──────────────────┬──────────────────────────────────────────┘
│
│ HTTP/REST Calls
│
┌──────────────────▼──────────────────────────────────────────┐
│ ObjectQL API Server │
│ │
│ • Object Definitions (Metadata) │
│ • Automatic CRUD Endpoints │
│ • Business Logic & Validation │
│ • Database Abstraction │
└──────────────────────────────────────────────────────────────┘
npm install @object-ui/react @object-ui/components @object-ui/data-objectqlimport React from 'react';
import { SchemaRenderer } from '@object-ui/react';
import { registerDefaultRenderers } from '@object-ui/components';
import { ObjectQLDataSource } from '@object-ui/data-objectql';
// Register Object UI components
registerDefaultRenderers();
// Create ObjectQL data source
const dataSource = new ObjectQLDataSource({
baseUrl: 'https://api.example.com',
token: 'your-auth-token', // Optional
spaceId: 'workspace123', // Optional for multi-tenant
});
// Define your schema
const schema = {
type: 'page',
title: 'Contacts',
body: {
type: 'data-table',
api: 'contacts', // ObjectQL object name
columns: [
{ name: 'name', label: 'Name' },
{ name: 'email', label: 'Email' },
{ name: 'phone', label: 'Phone' },
{ name: 'status', label: 'Status' }
]
}
};
function App() {
return <SchemaRenderer schema={schema} dataSource={dataSource} />;
}
export default App;Fetch data with automatic state management:
import { useObjectQL, useObjectQLQuery } from '@object-ui/data-objectql';
function ContactList() {
const dataSource = useObjectQL({
config: { baseUrl: 'https://api.example.com' }
});
const { data, loading, error, refetch } = useObjectQLQuery(
dataSource,
'contacts',
{
$filter: { status: 'active' },
$orderby: { created: 'desc' },
$top: 20,
}
);
if (loading) return <div>Loading...</div>;
if (error) return <div>Error: {error.message}</div>;
return (
<div>
<button onClick={refetch}>Refresh</button>
<ul>
{data?.map(contact => (
<li key={contact._id}>{contact.name}</li>
))}
</ul>
</div>
);
}Perform create, update, and delete operations:
import { useObjectQL, useObjectQLMutation } from '@object-ui/data-objectql';
function ContactForm() {
const dataSource = useObjectQL({
config: { baseUrl: 'https://api.example.com' }
});
const { create, update, remove, loading } = useObjectQLMutation(
dataSource,
'contacts'
);
const handleCreate = async () => {
await create({
name: 'John Doe',
email: 'john@example.com',
status: 'active'
});
};
return (
<div>
<button onClick={handleCreate} disabled={loading}>
Create Contact
</button>
</div>
);
}Object UI uses universal query parameters that are automatically converted to ObjectQL format:
await dataSource.find('contacts', {
$select: ['name', 'email', 'account.name']
});await dataSource.find('contacts', {
$filter: {
status: 'active',
age: { $gte: 18 }
}
});await dataSource.find('contacts', {
$orderby: { created: 'desc' },
$skip: 20,
$top: 10
});interface ObjectQLConfig {
baseUrl: string; // Required: ObjectQL server URL
version?: string; // API version (default: 'v1')
token?: string; // Authentication token
spaceId?: string; // Workspace/tenant ID
headers?: Record<string, string>;
timeout?: number; // Request timeout (default: 30000ms)
withCredentials?: boolean; // Include credentials (default: true)
}- Package README - Detailed API reference
- ObjectQL Documentation
- Component Library