Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Use data from API in variants view
Marcin Gębala4b9b731174a9
diff --git a/saleor/graphql/api.py b/saleor/graphql/api.pyindex 957b8a68f5..a3ceafb8a6 100644--- a/saleor/graphql/api.py+++ b/saleor/graphql/api.py@@ -46,7 +46,8 @@ from .product.resolvers import (resolve_attributes, resolve_categories, resolve_collections,resolve_products, resolve_product_types)from .product.types import (- Category, Collection, Product, ProductAttribute, ProductType)+ Category, Collection, Product, ProductAttribute, ProductType,+ ProductVariant)from .shipping.resolvers import resolve_shipping_methodsfrom .shipping.types import ShippingMethodfrom .shipping.mutations import (@@ -127,6 +128,9 @@ class Query(graphene.ObjectType):shop = graphene.Field(Shop, description='Represents a shop resources.',resolver=resolve_shop)+ variant = graphene.Field(+ ProductVariant, id=graphene.Argument(graphene.ID),+ description='Lookup a variant by ID.')voucher = graphene.Field(Voucher, id=graphene.Argument(graphene.ID),description='Lookup a voucher by ID.')@@ -215,6 +219,9 @@ class Query(graphene.ObjectType):def resolve_sales(self, info, query=None, **kwargs):return resolve_sales(info, query)+ def resolve_variant(self, info, id):+ return get_node(info, id, only_type=ProductVariant)+@permission_required('discount.view_voucher')def resolve_voucher(self, info, id):return get_node(info, id, only_type=Voucher)