balder
Advanced tools
@@ -9,5 +9,3 @@ from typing import List, Union | ||
| class BaseSubscription(channels_graphql_ws.Subscription): | ||
| @classmethod | ||
@@ -21,7 +19,5 @@ def subscribe(cls, root, info, *args, **kwargs): | ||
| except ImportError as e: | ||
| BaseSubscription = None | ||
| BaseSubscription = None | ||
| import graphene | ||
@@ -33,2 +29,3 @@ | ||
| class NoMutateException(Exception): | ||
@@ -39,9 +36,7 @@ pass | ||
| class BalderSubscription(metaclass=BalderSubscriptionMeta): | ||
| Arguments = None # Should be overwriten by the actual mutation | ||
| Arguments = None # Should be overwriten by the actual mutation | ||
| class Meta: | ||
| abstract = True | ||
| @classmethod | ||
@@ -72,3 +67,4 @@ def _get_description(cls) -> str: | ||
| """ | ||
| if cls._meta.operation is not None: return cls._meta.operation | ||
| if cls._meta.operation is not None: | ||
| return cls._meta.operation | ||
| return classToString(cls) | ||
@@ -90,25 +86,40 @@ | ||
| @classmethod | ||
| def _to_field(cls) -> graphene.Field: | ||
| meta = cls._meta | ||
| assert meta.type is not None, f"Please provide a Meta class with at least the attribute type in {cls.__name__}" | ||
| assert cls.Arguments is not None, f'Please provide a Arguments class (can just pass in body if no arguments are needed) in {cls.__name__}' | ||
| assert ( | ||
| meta.type is not None | ||
| ), f"Please provide a Meta class with at least the attribute type in {cls.__name__}" | ||
| assert ( | ||
| cls.Arguments is not None | ||
| ), f"Please provide a Arguments class (can just pass in body if no arguments are needed) in {cls.__name__}" | ||
| subscribe_function = cls._get_subscribe_or_none() | ||
| assert subscribe_function is not None, f"Please provide a subscribe function in {cls.__name__}" | ||
| assert ( | ||
| subscribe_function is not None | ||
| ), f"Please provide a subscribe function in {cls.__name__}" | ||
| publish_function = cls._get_publish_or_none() | ||
| if publish_function is None: | ||
| assert meta.serializer is not None, "If you omit publish please provide a Meta field serializer in {cls.__name__}" | ||
| publish_function = lambda payload, info, *args, **kwargs: meta.serializer.unpack(payload, basemodel=meta.model) | ||
| assert ( | ||
| meta.serializer is not None | ||
| ), "If you omit publish please provide a Meta field serializer in {cls.__name__}" | ||
| publish_function = ( | ||
| lambda payload, info, *args, **kwargs: meta.serializer.unpack( | ||
| payload, basemodel=meta.model | ||
| ) | ||
| ) | ||
| cls.subscription = type("Subscription", (BaseSubscription,), {"Arguments": cls.Arguments, "Output": meta.type, "subscribe": subscribe_function, "publish": publish_function, "__doc__": cls._get_description()}) | ||
| cls.subscription = type( | ||
| "Subscription", | ||
| (BaseSubscription,), | ||
| { | ||
| "Arguments": cls.Arguments, | ||
| "Output": meta.type, | ||
| "subscribe": subscribe_function, | ||
| "publish": publish_function, | ||
| "__doc__": cls._get_description(), | ||
| "__metaclass__": BaseSubscription.__metaclass__, | ||
| }, | ||
| ) | ||
| return cls.subscription.Field(description=cls._get_description()) | ||
+1
-1
| Metadata-Version: 2.1 | ||
| Name: balder | ||
| Version: 0.1.26 | ||
| Version: 0.1.27 | ||
| Summary: | ||
@@ -5,0 +5,0 @@ Author: jhnnsrs |
+1
-1
| [tool.poetry] | ||
| name = "balder" | ||
| version = "0.1.26" | ||
| version = "0.1.27" | ||
| description = "" | ||
@@ -5,0 +5,0 @@ authors = ["jhnnsrs <jhnnsrs@gmail.com>"] |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
41066
0.91%802
3.08%