How to use the graphene-django.graphene_django.compat.RelatedObject function in graphene-django

To help you get started, we’ve selected a few graphene-django examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github graphql-python / graphene / graphene-django / graphene_django / utils.py View on Github external
def get_reverse_fields(model):
    for name, attr in model.__dict__.items():
        # Django =>1.9 uses 'rel', django <1.9 uses 'related'
        related = getattr(attr, 'rel', None) or \
            getattr(attr, 'related', None)
        if isinstance(related, RelatedObject):
            # Hack for making it compatible with Django 1.6
            new_related = RelatedObject(related.parent_model, related.model, related.field)
            new_related.name = name
            yield new_related
        elif isinstance(related, models.ManyToOneRel):
            yield related
        elif isinstance(related, models.ManyToManyRel) and not related.symmetrical:
            yield related
github graphql-python / graphene / graphene-django / graphene_django / utils.py View on Github external
def get_reverse_fields(model):
    for name, attr in model.__dict__.items():
        # Django =>1.9 uses 'rel', django <1.9 uses 'related'
        related = getattr(attr, 'rel', None) or \
            getattr(attr, 'related', None)
        if isinstance(related, RelatedObject):
            # Hack for making it compatible with Django 1.6
            new_related = RelatedObject(related.parent_model, related.model, related.field)
            new_related.name = name
            yield new_related
        elif isinstance(related, models.ManyToOneRel):
            yield related
        elif isinstance(related, models.ManyToManyRel) and not related.symmetrical:
            yield related
github graphql-python / graphene / graphene-django / graphene_django / converter.py View on Github external
@convert_django_field.register(RelatedObject)
def convert_relatedfield_to_djangomodel(field, registry=None):
    model = field.model

    def dynamic_type():
        _type = registry.get_type_for_model(model)
        if not _type:
            return

        if is_node(_type):
            return get_connection_field(_type)
        return Field(List(_type))

    return Dynamic(dynamic_type)