Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add descriptions to GraphQL types
Marcin Gębaladfa9321ee1d4
diff --git a/saleor/dashboard/graphql/api.py b/saleor/dashboard/graphql/api.pyindex ef240a6d92..426ea8b2dd 100644--- a/saleor/dashboard/graphql/api.py+++ b/saleor/dashboard/graphql/api.py@@ -23,12 +23,18 @@ class Query(graphene.ObjectType):categories = DjangoFilterConnectionField(Category, filterset_class=DistinctFilterSet,- level=graphene.Argument(graphene.Int))- category = graphene.Field(Category, id=graphene.Argument(graphene.ID))-- page = graphene.Field(Page, id=graphene.Argument(graphene.ID))+ level=graphene.Argument(graphene.Int),+ description="A list of shop's categories.")+ category = graphene.Field(+ Category, id=graphene.Argument(graphene.ID),+ description="Lookup a category by ID.")++ page = graphene.Field(+ Page, id=graphene.Argument(graphene.ID),+ description="Lookup a page by ID.")pages = DjangoFilterConnectionField(- Page, filterset_class=DistinctFilterSet)+ Page, filterset_class=DistinctFilterSet,+ description="A list of shop's pages.")product = graphene.Field(Product, id=graphene.Argument(graphene.ID))products = DjangoFilterConnectionField(@@ -73,13 +79,8 @@ class Mutations(graphene.ObjectType):page_delete = PageDelete.Field()page_update = PageUpdate.Field()- product_create = ProductCreateMutation.Field()- product_delete = ProductDeleteMutation.Field()- product_update = ProductUpdateMutation.Field()-- token_auth = graphql_jwt.ObtainJSONWebToken.Field()- verify_token = graphql_jwt.Verify.Field()- refresh_token = graphql_jwt.Refresh.Field()+ access_token_create = graphql_jwt.ObtainJSONWebToken.Field()+ access_token_renew = graphql_jwt.Refresh.Field()schema = graphene.Schema(Query, Mutations)diff --git a/saleor/dashboard/graphql/core/__init__.py b/saleor/dashboard/graphql/core/__init__.pynew file mode 100644index 0000000000..8b13789179--- /dev/null+++ b/saleor/dashboard/graphql/core/__init__.py@@ -0,0 +1 @@+diff --git a/saleor/dashboard/graphql/mutations.py b/saleor/dashboard/graphql/core/mutations.pysimilarity index 96%rename from saleor/dashboard/graphql/mutations.pyrename to saleor/dashboard/graphql/core/mutations.pyindex 871d78bab8..c15ca8dab5 100644--- a/saleor/dashboard/graphql/mutations.py+++ b/saleor/dashboard/graphql/core/mutations.py@@ -7,9 +7,8 @@ from graphene_django.form_converter import convert_form_fieldfrom graphene_django.registry import get_global_registryfrom graphql_jwt.decorators import staff_member_required-from ...graphql.core.types import Error-from ...graphql.utils import get_node-from .utils import get_attributes_dict_from_list+from ....graphql.core.types import Error+from ....graphql.utils import get_noderegistry = get_global_registry()@@ -48,7 +47,9 @@ def get_output_fields(model, return_field_name):class BaseMutation(graphene.Mutation):- errors = graphene.List(Error)+ errors = graphene.List(+ Error,+ description="List of errors that occurred executing the mutation.")class Meta:abstract = Truediff --git a/saleor/dashboard/graphql/page/mutations.py b/saleor/dashboard/graphql/page/mutations.pyindex 40fce14695..cf33654e08 100644--- a/saleor/dashboard/graphql/page/mutations.py+++ b/saleor/dashboard/graphql/page/mutations.py@@ -2,21 +2,24 @@ import graphenefrom ....page import modelsfrom ...page.forms import PageForm-from ..mutations import (+from ..core.mutations import (ModelDeleteMutation, ModelFormMutation, ModelFormUpdateMutation,StaffMemberRequiredMutation)class PageCreate(StaffMemberRequiredMutation, ModelFormMutation):class Meta:+ description = "Creates a new page."form_class = PageFormclass PageUpdate(StaffMemberRequiredMutation, ModelFormUpdateMutation):class Meta:+ description = "Updates a existing page."form_class = PageFormclass PageDelete(StaffMemberRequiredMutation, ModelDeleteMutation):class Meta:+ description = "Permanently deletes a page."model = models.Pagediff --git a/saleor/dashboard/graphql/product/mutations.py b/saleor/dashboard/graphql/product/mutations.pyindex dc730347c2..85cd5ad6c0 100644--- a/saleor/dashboard/graphql/product/mutations.py+++ b/saleor/dashboard/graphql/product/mutations.py@@ -5,7 +5,7 @@ from ....graphql.product.types import Category, ProductTypefrom ....graphql.utils import get_nodefrom ....product import modelsfrom ...category.forms import CategoryForm-from ..mutations import (+from ..core.mutations import (BaseMutation, ModelDeleteMutation, ModelFormMutation,ModelFormUpdateMutation, StaffMemberRequiredMutation, convert_form_errors)from ..utils import get_attributes_dict_from_list@@ -17,6 +17,7 @@ class CategoryCreateMutation(StaffMemberRequiredMutation, ModelFormMutation):parent_id = graphene.ID()class Meta:+ description = "Creates a new category."form_class = CategoryForm@classmethod@@ -34,6 +35,7 @@ class CategoryCreateMutation(StaffMemberRequiredMutation, ModelFormMutation):class CategoryUpdateMutation(StaffMemberRequiredMutation, ModelFormUpdateMutation):class Meta:+ description = "Updates a existing category."form_class = CategoryForm@classmethod@@ -45,6 +47,7 @@ class CategoryUpdateMutation(class CategoryDelete(StaffMemberRequiredMutation, ModelDeleteMutation):class Meta:+ description = "Permanently deletes a category."model = models.Categorydiff --git a/saleor/graphql/api.py b/saleor/graphql/api.pyindex 9d045c5de7..f01b577dcf 100644--- a/saleor/graphql/api.py+++ b/saleor/graphql/api.py@@ -14,27 +14,32 @@ from .utils import get_nodeclass Query(graphene.ObjectType):- node = graphene.Node.Field()- debug = graphene.Field(DjangoDebug, name='__debug')-+ attributes = DjangoFilterConnectionField(+ ProductAttribute, filterset_class=DistinctFilterSet,+ in_category=graphene.Argument(graphene.ID),+ description="A list of the shop's attributes.")categories = DjangoFilterConnectionField(Category, filterset_class=DistinctFilterSet,- level=graphene.Argument(graphene.Int))- category = graphene.Field(Category, id=graphene.Argument(graphene.ID))-+ level=graphene.Argument(graphene.Int),+ description="A list of the shop's categories.")+ category = graphene.Field(+ Category, id=graphene.Argument(graphene.ID),+ description="Lookup a category by ID.")page = graphene.Field(- Page, id=graphene.Argument(graphene.ID), slug=graphene.String())+ Page, id=graphene.Argument(graphene.ID), slug=graphene.String(),+ description="Lookup a page by ID or by slug.")pages = DjangoFilterConnectionField(Page, filterset_class=DistinctFilterSet,- level=graphene.Argument(graphene.Int))-- attributes = DjangoFilterConnectionField(- ProductAttribute,- filterset_class=DistinctFilterSet,- in_category=graphene.Argument(graphene.ID))- product = graphene.Field(Product, id=graphene.Argument(graphene.ID))+ level=graphene.Argument(graphene.Int),+ description="A list of the shop's pages.")+ product = graphene.Field(+ Product, id=graphene.Argument(graphene.ID),+ description="Lookup a product by ID.")products = DjangoFilterConnectionField(- Product, filterset_class=ProductFilterSet)+ Product, filterset_class=ProductFilterSet,+ description="A list of the shop's products.")+ node = graphene.Node.Field()+ debug = graphene.Field(DjangoDebug, name='__debug')def resolve_category(self, info, id):return get_node(info, id, only_type=Category)@@ -62,9 +67,8 @@ class Query(graphene.ObjectType):class Mutations(graphene.ObjectType):- token_auth = graphql_jwt.ObtainJSONWebToken.Field()- verify_token = graphql_jwt.Verify.Field()- refresh_token = graphql_jwt.Refresh.Field()+ access_token_create = graphql_jwt.ObtainJSONWebToken.Field()+ access_token_renew = graphql_jwt.Refresh.Field()schema = graphene.Schema(Query, Mutations)diff --git a/saleor/graphql/core/types.py b/saleor/graphql/core/types.pyindex d426877e47..d8088183c7 100644--- a/saleor/graphql/core/types.py+++ b/saleor/graphql/core/types.py@@ -32,12 +32,18 @@ class Error(graphene.ObjectType):field = graphene.String()message = graphene.String()+ class Meta:+ description = "Represents an error in the input of a mutation."+class Money(graphene.ObjectType):- currency = graphene.String()+ currency = graphene.String(description="")amount = graphene.Float()localized = graphene.String()+ class Meta:+ description = "Represents money."+def resolve_localized(self, info):return prices_i18n.amount(self)@@ -47,7 +53,13 @@ class TaxedMoney(graphene.ObjectType):gross = graphene.Field(Money)net = graphene.Field(Money)+ class Meta:+ description = "Represents taxed money."+class TaxedMoneyRange(graphene.ObjectType):start = graphene.Field(TaxedMoney)stop = graphene.Field(TaxedMoney)++ class Meta:+ description = "Represents a range of monetary values."