cli
cli copied to clipboard
Add GraphQL Operation Validation for Bulk Operations CLI
Resolves: https://github.com/orgs/shop/projects/208/views/34?pane=issue&itemId=139461468&issue=shop%7Cissues-api-foundations%7C1114 and https://github.com/orgs/shop/projects/208/views/34?pane=issue&itemId=139446074&issue=shop%7Cissues-api-foundations%7C1112
Why are these changes introduced?
Improves the validation and error handling for GraphQL operations in the bulk operations service.
Implementation Details
- Enhances GraphQL document validation to ensure exactly one operation definition is present (error handling for cases that don't have exactly one operation)
- Additional unit tests added that prove core automatically rejects malformed documents (we don't have to do this).
- Created new
validateGraphQLDocument()function that consolidates all GraphQL validation in one place:- Validates exactly one operation definition exists
- Validates --variables flag is only used with mutations
- Checks if the operation is a mutation (returns boolean that is used later). This replaces the previous
isMutation()function.
Testing
Unit tests in execute-bulk-operation.test.ts