Skip to content

Migrate @object-ui/data-objectql to @objectql/sdk v1.8.2 - #38

Merged
huangyiirene merged 12 commits into
mainfrom
copilot/update-objectql-to-latest-version
Jan 14, 2026
Merged

Migrate @object-ui/data-objectql to @objectql/sdk v1.8.2#38
huangyiirene merged 12 commits into
mainfrom
copilot/update-objectql-to-latest-version

Conversation

CopilotAI commented Jan 14, 2026

Copy link
Copy Markdown
Contributor

Plan: Update @object-ui/data-objectql to use @objectql/sdk

  • Add @objectql/sdk as a dependency to @object-ui/data-objectql package.json
  • Refactor ObjectQLDataSource to use @objectql/sdk client instead of direct fetch calls
  • Update imports and type definitions to use @objectql/types from the SDK
  • Update tests to work with the new SDK-based implementation
  • Verify the build passes
  • Update documentation to reflect SDK usage
  • Run final tests to ensure everything works
  • Address code review feedback
  • Fix operator precedence in type cast
  • Implement MongoDB-like operator conversion ($gte, $lte, $in, etc.)
  • Improve bulk operations to support both id and _id fields
  • Fix hooks dependency array syntax error
  • Add clarifying comment for PUT method in update test

Summary

Successfully updated @object-ui/data-objectql to use the official @objectql/sdk package (v1.8.2) and addressed all code review feedback.

Latest Changes:

  1. Fixed hooks.ts: Removed duplicate dependency array syntax error
  2. Fixed operator precedence: Changed response as T || null to response ? (response as T) : null
  3. Enhanced filter conversion: Now handles MongoDB-like operators ($gte, $lte, $gt, $lt, $in, $nin, etc.)
  4. Improved bulk operations:
    • Support both id and _id fields
    • Better error messages
    • Proper handling of update payloads (excludes id from update data)
    • Delete operations support both objects and direct ID values
  5. Added test: New test case for MongoDB operator conversion
  6. Test clarification: Added comment explaining that the SDK uses PUT (not PATCH) for updates

Test Results:

  • ✅ All 14 tests passing
  • ✅ Build successful
  • ✅ No TypeScript errors
Original prompt

更新到objectql最新版,此时'@object-ui/data-objectql'应依赖 @objectql/sdk


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
@vercel

vercelBot commented Jan 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentReviewUpdated (UTC)
objectui-playgroundReadyReadyPreview, CommentJan 14, 2026 6:23pm

Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
…ement bulk operations
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the @object-ui/data-objectql package to use the official @objectql/sdk (v1.8.2) for API communication, replacing custom fetch logic with the SDK's DataApiClient. The changes improve reliability and maintainability by leveraging the official ObjectQL client.

Changes:

  • Added dependencies on @objectql/sdk and @objectql/types packages
  • Refactored ObjectQLDataSource to wrap the SDK's DataApiClient instead of implementing custom HTTP requests
  • Updated configuration interface to align with SDK's DataApiClientConfig, removing deprecated options (version, spaceId, withCredentials)
  • Updated all tests to match SDK response formats (items/meta instead of value/@odata.count)
  • Enhanced documentation with SDK integration details and migration guide

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
FileDescription
packages/data-objectql/package.jsonAdded dependencies for @objectql/sdk and @objectql/types
packages/data-objectql/src/ObjectQLDataSource.tsReplaced custom fetch implementation with SDK's DataApiClient, updated filter and sort parameter formats
packages/data-objectql/src/tests/ObjectQLDataSource.test.tsUpdated test expectations to match SDK response structure and removed deprecated configuration tests
packages/data-objectql/src/hooks.tsRemoved spaceId from useMemo dependency array
packages/data-objectql/README.mdUpdated documentation with SDK integration details and migration guide
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment threadpackages/data-objectql/src/hooks.ts Outdated
return filtered as T;
}

return response as T || null;

CopilotAIJan 14, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expression response as T || null will evaluate to null when response is falsy, but the type cast happens before the nullish check. This should be (response as T) || null or better yet, response ? (response as T) : null for clarity.

Suggested change
returnresponseasT||null;
returnresponse? (responseasT) :null;

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit f58a57c. Changed to response ? (response as T) : null for proper operator precedence.

Comment on lines +349 to +354
// For bulk updates with SDK, we need filters and update data
// This is a limitation - the old API accepted array of records
// The new SDK requires filters + data
if (Array.isArray(data)) {
// If array of records is provided, we need to update them individually
// This is less efficient but maintains compatibility

CopilotAIJan 14, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bulk update and delete operations throw errors indicating they are not implemented, but this breaking change is not mentioned in the PR description or README migration guide. Users relying on these operations will experience runtime failures.

Suggested change
// For bulk updates with SDK, we need filters and update data
// This is a limitation - the old API accepted array of records
// The new SDK requires filters + data
if(Array.isArray(data)){
// If array of records is provided, we need to update them individually
// This is less efficient but maintains compatibility
// Fallback implementation: iterate and call single-record update
constresults: T[]=[];
for(constitemofdata){
constrecord: any=itemasany;
constid=record?.id;
if(id===undefined||id===null){
thrownewError(
'Bulk update requires each item to include an `id` field.'
);
}
// Do not send id as part of the update payload
const{id: _omitId, ...updateData}=record;
constupdated=awaitthis.client.update<T>(resource,id,updateData);
if(updated!==undefined&&updated!==null){
results.push(updated);
}
}
returnresults;
}elseif(operation==='delete'){
// Fallback implementation: iterate and call single-record delete
for(constitemofdata){
constrecord: any=itemasany;
constid=record?.id??record;
if(id===undefined||id===null){
thrownewError(
'Bulk delete requires each item to include an `id` field or be an id value.'
);
}
awaitthis.client.delete(resource,id);
}
// For delete operations, we return an empty array by convention
return[];

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit f58a57c. Implemented proper bulk update and delete operations that:

  • Support both id and _id fields
  • Exclude id fields from update payload
  • Support direct ID values for delete operations
  • Return appropriate results (array for update, empty array for delete)
  • Provide clear error messages

Comment on lines +159 to +162
// Convert object format to FilterExpression format
objectqlParams.filter = Object.entries(params.$filter).map(
([key, value]) => [key, '=', value] as [string, string, any]
) as FilterExpression;

CopilotAIJan 14, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The filter conversion assumes all object-format filters use the '=' operator. This is incorrect for MongoDB-like syntax where params.$filter could be { age: { $gte: 18 } }. The conversion doesn't handle nested operators and will produce invalid filters like ['age', '=', { $gte: 18 }].

Suggested change
// Convert object format to FilterExpression format
objectqlParams.filter=Object.entries(params.$filter).map(
([key,value])=>[key,'=',value]as[string,string,any]
)asFilterExpression;
// Convert object format (including Mongo-like operator objects) to FilterExpression format
constfilterEntries=Object.entries(params.$filter);
constfilters: any[]=[];
constoperatorMap: Record<string,string>={
$eq: '=',
$ne: '!=',
$gt: '>',
$gte: '>=',
$lt: '<',
$lte: '<=',
$in: 'in',
$nin: 'not-in',
};
for(const[key,value]offilterEntries){
constisPlainObject=
value!==null&&
typeofvalue==='object'&&
!Array.isArray(value);
if(isPlainObject){
constopEntries=Object.entries(valueasRecord<string,unknown>);
consthasDollarOperator=opEntries.some(([op])=>op.startsWith('$'));
if(hasDollarOperator){
for(const[rawOp,opValue]ofopEntries){
constmappedOp=
operatorMap[rawOpaskeyoftypeofoperatorMap]??
rawOp.replace(/^\$/,'');
filters.push([key,mappedOp,opValue]);
}
continue;
}
}
// Fallback: treat as simple equality
filters.push([key,'=',value]);
}
objectqlParams.filter=filtersasFilterExpression;

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit f58a57c. Implemented complete MongoDB-like operator conversion supporting $eq, $ne, $gt, $gte, $lt, $lte, $in, $nin. Added test case to verify the conversion works correctly.

const options = fetchCall[1];

expect(options.method).toBe('PATCH');
expect(options.method).toBe('PUT');

CopilotAIJan 14, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test expects 'PUT' method but doesn't verify that the SDK's update method actually uses PUT. The change from PATCH to PUT in the test suggests the HTTP method changed, but there's no test verifying the SDK client's actual behavior.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot fix

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test correctly reflects the SDK's behavior. The @objectql/sdk's DataApiClient uses PUT for update operations (line 63 in SDK's index.d.ts shows update method). The test was updated to match this actual SDK behavior rather than assuming PATCH.

Comment threadpackages/data-objectql/README.md Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
CopilotAI changed the title [WIP] Update to latest version of objectql with sdk dependencyMigrate @object-ui/data-objectql to @objectql/sdk v1.8.2Jan 14, 2026
…n, bulk operations, and hooks dependency array
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
@huangyiirene

Copy link
Copy Markdown
Collaborator

@copilot fix

Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>

CopilotAI commented Jan 14, 2026

Copy link
Copy Markdown
ContributorAuthor

@copilot fix

Fixed in commit a1910e4. Added clarifying comment in the test explaining that the SDK uses PUT method (not PATCH) for updates, which is the standard behavior of @objectql/sdk's DataApiClient.

@github-actions

Copy link
Copy Markdown
Contributor

✅ All checks passed!

  • ✅ Type check passed
  • ✅ Tests passed
  • ✅ Lint check completed

@github-actions

Copy link
Copy Markdown
Contributor

✅ All checks passed!

  • ✅ Type check passed
  • ✅ Tests passed
  • ✅ Lint check completed

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

✅ All checks passed!

  • ✅ Type check passed
  • ✅ Tests passed
  • ✅ Lint check completed

@huangyiirene
huangyiirene marked this pull request as ready for review January 14, 2026 18:25
@huangyiirene
huangyiirene merged commit 87d5848 into mainJan 14, 2026
7 checks passed
CopilotAI added a commit that referenced this pull request Feb 23, 2026
- #39 showRecordCount: conditionally show/hide record count bar
- #24 rowHeight: add short and extra_tall mapping in ListView + bridge
- #7 sort: parse legacy string format "field desc"
- #22 description: render view description below toolbar
- #40 allowPrinting: add print button with window.print()
- #31 virtualScroll: forward flag to grid view schema
- #35 userActions: wire sort/search/filter/rowHeight to toolbar visibility
- #38 addRecord: render "+ Add Record" button from spec config
- #37 tabs: render tab bar UI for view tabs
- #9 filterableFields: restrict FilterBuilder to whitelist fields
- #8 searchableFields: scope search queries to specified fields
- #36 appearance: wire showDescription and allowedVisualizations
- #16 pageSizeOptions: add page size selector UI in status bar
- #17-21: use spec kanban/calendar/gantt/gallery/timeline configs
- #20 gallery: add typed GalleryConfig to ListViewSchema
- #21 timeline: add typed TimelineConfig to ListViewSchema
- Bridge: add short/extra_tall density mapping, filterableFields pass-through
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@huangyiirene@qq9340100