-
Notifications
You must be signed in to change notification settings - Fork 0
Add metaobject instances management API #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Implements the delete_metaobject_definition method to complete the CRUD operations for metaobject definitions management API. The method follows the same patterns as create and update methods, including proper error handling and logging. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Implements create_metaobject for creating metaobject instances - Adds find_metaobject to retrieve single metaobjects by handle - Adds find_metaobjects to query multiple metaobjects with filtering - Implements update_metaobject for modifying existing instances - Implements delete_metaobject for removing metaobject instances - Supports both handle and GID-based operations - Includes proper error handling and user feedback - Follows existing code patterns and conventions - Updates README roadmap to mark completion 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
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 introduces full CRUD support for Shopify metaobject instances and updates documentation to reflect completed functionality.
- Adds
create_metaobject
,find_metaobject(s)
,update_metaobject
, anddelete_metaobject
methods with GraphQL implementations and error handling. - Updates README checklist to mark metaobject instances management API and delete functionality as completed.
- Leverages
log_time
for write operations and integrates with existing error handling patterns.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
lib/shopify_toolkit/metaobject_statements.rb | Implements CRUD methods for managing metaobject instances via GraphQL |
README.md | Fixes roadmap items to mark delete and instances API as completed |
Comments suppressed due to low confidence (1)
README.md:20
- The markdown list items for Delete and Metaobject Instances management API are misaligned; please fix indentation and bullet syntax to ensure these checklist entries render correctly.
- [x] Delete
|
||
metaobject_input = { type: type.to_s, **options } | ||
metaobject_input[:handle] = handle if handle | ||
metaobject_input[:fields] = fields.map { |field| { key: field[:key].to_s, value: field[:value].to_s } } if fields.any? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Casting all field values to strings may lead to invalid types for non-string fields; consider preserving original value types or converting based on the metaobject field definitions.
metaobject_input[:fields] = fields.map { |field| { key: field[:key].to_s, value: field[:value].to_s } } if fields.any? | |
metaobject_input[:fields] = fields.map { |field| { key: field[:key].to_s, value: field[:value] } } if fields.any? |
Copilot uses AI. Check for mistakes.
def create_metaobject(type, handle: nil, fields: [], **options) | ||
# Check if metaobject definition exists | ||
unless get_metaobject_definition_gid(type) | ||
raise "Metaobject definition #{type} does not exist. Create it first." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Raising a generic RuntimeError makes it harder to handle this specific error downstream; consider defining and using a more descriptive or custom exception class.
raise "Metaobject definition #{type} does not exist. Create it first." | |
raise MetaobjectDefinitionError, "Metaobject definition #{type} does not exist. Create it first." |
Copilot uses AI. Check for mistakes.
This pull request implements comprehensive metaobject instances management functionality, extending the
ShopifyToolkit::MetaobjectStatements
module with full CRUD operations for metaobject instances.New functionality for managing Shopify metaobject instances:
Method
create_metaobject
: Creates new metaobject instances with validation to ensure the metaobject definition exists. Includes built-in checks to skip creation if an instance with the same handle already exists. (lib/shopify_toolkit/metaobject_statements.rb)Method
find_metaobject
: Retrieves a single metaobject instance by type and handle, returning the complete metaobject data including all fields. (lib/shopify_toolkit/metaobject_statements.rb)Method
find_metaobjects
: Queries multiple metaobjects by type with support for filtering, sorting, and pagination. Supports all Shopify GraphQL query parameters including first, query filters, sortKey, and reverse ordering. (lib/shopify_toolkit/metaobject_statements.rb)Method
update_metaobject
: Updates existing metaobject instances by handle or GID. Gracefully handles cases where the metaobject doesn't exist with user-friendly feedback. (lib/shopify_toolkit/metaobject_statements.rb)Method
delete_metaobject
: Deletes metaobject instances by handle or GID with proper error handling and user feedback for non-existent objects. (lib/shopify_toolkit/metaobject_statements.rb)Key features:
handle_shopify_admin_client_errors
methodlog_time
decorator for performance monitoring on write operationsImplementation details:
metaobjectCreate
,metaobjectUpdate
, andmetaobjectDelete
mutationsmetaobject
andmetaobjects
queries for data retrievalDocumentation updates: