diff --git a/CHANGELOG.md b/CHANGELOG.md index fa7f6d8..5a3d860 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Release Notes for Shopify +## Unreleased + +- `shopifyId` and `shopifyGid` fields are now available when query product variants via GraphQL. ([#211](https://github.com/craftcms/shopify/issues/211)) + ## 7.1.0 - 2026-04-08 - Added support for querying for products via GraphQL. ([#49](https://github.com/craftcms/shopify/discussions/49), [#203](https://github.com/craftcms/shopify/issues/203), [#206](https://github.com/craftcms/shopify/pull/206)) diff --git a/src/gql/types/Variant.php b/src/gql/types/Variant.php index 5e6b05e..b80276c 100644 --- a/src/gql/types/Variant.php +++ b/src/gql/types/Variant.php @@ -50,7 +50,19 @@ public static function getFieldDefinitions(): array 'id' => [ 'name' => 'id', 'type' => Type::string(), + 'description' => 'ID of the variant.', + ], + 'shopifyId' => [ + 'name' => 'shopifyId', + 'type' => Type::string(), + 'description' => 'Shopify ID of the variant.', + 'resolve' => fn(VariantElement $source) => str_replace('gid://shopify/ProductVariant/', '', $source->shopifyId), + ], + 'shopifyGid' => [ + 'name' => 'shopifyGid', + 'type' => Type::string(), 'description' => 'Shopify GID of the variant.', + 'resolve' => fn(VariantElement $source) => $source->shopifyId, ], 'title' => [ 'name' => 'title',