INNER CODE UNIT · Python

__init__

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

    def __init__(self, results, count, results_field_name="results"):
        """Initialize the Django list object."""
        self.results = results
        self.count = count
        self.results_field_name = results_field_name

    def to_dict(self):
        """Convert the object to a dictionary."""
        return {
            self.results_field_name: [e.to_dict() for e in self.results],
            "count": self.count,
        }


def resolver(attr_name, root, instance, info):
    """Resolve generic foreign key attributes."""
    if attr_name == "app_label":
        return instance._meta.app_label

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…