Skip to content

Commit eb87499

Browse files
Copilothuangyiirene
andcommitted
Update documentation to reflect @objectql/sdk integration
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
1 parent 418e356 commit eb87499

1 file changed

Lines changed: 56 additions & 8 deletions

File tree

packages/data-objectql/README.md

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
11
# @object-ui/data-objectql
22

3-
ObjectQL Data Source Adapter for Object UI - Seamlessly connect your Object UI components with ObjectQL API backends.
3+
ObjectQL Data Source Adapter for Object UI - Seamlessly connect your Object UI components with ObjectQL API backends using the official **@objectql/sdk**.
44

55
## Features
66

7+
-**Official SDK Integration** - Built on top of @objectql/sdk for reliable API communication
78
-**Universal DataSource Interface** - Implements the standard Object UI data source protocol
89
-**Full TypeScript Support** - Complete type definitions and IntelliSense
910
-**React Hooks** - Easy-to-use hooks for data fetching and mutations
1011
-**Automatic Query Conversion** - Converts universal query params to ObjectQL format
1112
-**Error Handling** - Robust error handling with typed error responses
1213
-**Authentication** - Built-in support for token-based authentication
13-
-**Multi-tenant** - Space ID support for multi-tenant environments
14+
-**Universal Runtime** - Works in browsers, Node.js, and edge runtimes
1415

1516
## Installation
1617

1718
```bash
1819
# Using npm
19-
npm install @object-ui/data-objectql
20+
npm install @object-ui/data-objectql @objectql/sdk
2021

2122
# Using yarn
22-
yarn add @object-ui/data-objectql
23+
yarn add @object-ui/data-objectql @objectql/sdk
2324

2425
# Using pnpm
25-
pnpm add @object-ui/data-objectql
26+
pnpm add @object-ui/data-objectql @objectql/sdk
2627
```
2728

29+
**Note**: The package now depends on `@objectql/sdk` and `@objectql/types`, which provide the underlying HTTP client and type definitions.
30+
2831
## Quick Start
2932

3033
### Basic Usage
@@ -144,15 +147,14 @@ new ObjectQLDataSource(config: ObjectQLConfig)
144147
```typescript
145148
interface ObjectQLConfig {
146149
baseUrl: string; // ObjectQL API base URL
147-
version?: string; // API version (default: 'v1')
148150
token?: string; // Authentication token
149-
spaceId?: string; // Space ID for multi-tenant
150151
headers?: Record<string, string>; // Additional headers
151152
timeout?: number; // Request timeout (default: 30000ms)
152-
withCredentials?: boolean; // Include credentials (default: true)
153153
}
154154
```
155155

156+
**Note**: This configuration is compatible with `@objectql/sdk`'s `DataApiClientConfig`. Additional options supported by the SDK can also be passed.
157+
156158
#### Methods
157159

158160
##### find(resource, params)
@@ -378,6 +380,51 @@ const result = await dataSource.find('contacts');
378380
const contact: Contact = result.data[0]; // Typed!
379381
```
380382

383+
## Architecture
384+
385+
This adapter is built on top of the official ObjectQL SDK:
386+
387+
```
388+
Object UI Components
389+
390+
@object-ui/data-objectql (this package)
391+
392+
@objectql/sdk (DataApiClient)
393+
394+
ObjectQL Server API
395+
```
396+
397+
### Benefits of Using the Official SDK
398+
399+
- **Reliability**: Uses the official, well-tested ObjectQL HTTP client
400+
- **Compatibility**: Always compatible with the latest ObjectQL server versions
401+
- **Type Safety**: Leverages @objectql/types for consistent type definitions
402+
- **Universal Runtime**: Works in browsers, Node.js, Deno, and edge runtimes
403+
- **Automatic Updates**: SDK improvements automatically benefit this adapter
404+
405+
## Migration from Previous Versions
406+
407+
If you're upgrading from a previous version that used custom fetch logic:
408+
409+
1. Update your dependencies to include `@objectql/sdk`:
410+
```bash
411+
pnpm add @objectql/sdk @objectql/types
412+
```
413+
414+
2. The configuration interface has been simplified. Remove deprecated options:
415+
- `version` - The SDK handles API versioning internally
416+
- `spaceId` - Use custom headers if needed
417+
- `withCredentials` - The SDK manages this automatically
418+
419+
3. Filter formats now support both object and array notation:
420+
```typescript
421+
// Object format (converted to array internally)
422+
$filter: { status: 'active', age: 18 }
423+
424+
// Array format (FilterExpression - native ObjectQL format)
425+
$filter: [['status', '=', 'active'], ['age', '>=', 18]]
426+
```
427+
381428
## License
382429

383430
MIT
@@ -387,3 +434,4 @@ MIT
387434
- [Object UI Documentation](https://www.objectui.org)
388435
- [GitHub Repository](https://github.com/objectstack-ai/objectui)
389436
- [ObjectQL Documentation](https://www.objectql.com)
437+
- [ObjectQL SDK](https://github.com/objectstack-ai/objectql)

0 commit comments

Comments
 (0)