INNER CODE UNIT · Python

Binary

eamigo86/graphene-django-extras · graphene_django_extras/base_types.py:140

class Binary(graphene.Scalar):
    """BinaryArray is used to convert a Django BinaryField to the string form."""

    @staticmethod
    def binary_to_string(value):
        """Convert binary data to string representation."""
        return binascii.hexlify(value).decode("utf-8")

    serialize = binary_to_string
    parse_value = binary_to_string

    @classmethod
    def parse_literal(cls, node):
        """Parse literal node from GraphQL AST."""
        if isinstance(node, ast.StringValue):
            return cls.binary_to_string(node.value)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…