コード例 #1
0
def register_converters():
    """
    Register the custom converters in the graphene-django's registry.
    """
    convert_django_field.register(WagtailStreamField, convert_stream_field)
    convert_django_field.register(
        TaggableManager, convert_tags_to_list_of_strings
    )
コード例 #2
0
ファイル: apps.py プロジェクト: whitej6/nautobot
    def ready(self):
        super().ready()

        from graphene_django.converter import convert_django_field, convert_field_to_string
        from nautobot.ipam.fields import VarbinaryIPField

        # Register VarbinaryIPField to be converted to a string type
        convert_django_field.register(VarbinaryIPField)(
            convert_field_to_string)
コード例 #3
0
def register_model_and_form_fields(model_field, form_field, scalar,
                                   description):
    # The odd call syntax is because `register` is usually used as a decorator.
    # We want to avoid this, because if you use decorators at the top-level,
    # they might run multiple times, or not at the right time.
    # We want the registration process to happen once during the loading of
    # this app, so we do it in this function like this instead.
    convert_django_field.register(gis_models.PointField)(make_field_converter(
        scalar, description))
    convert_form_field.register(gis_forms.PointField)(make_field_converter(
        scalar, description))
コード例 #4
0
import graphene
from django.conf import settings
from graphene.relay import Node
from graphene_django.converter import convert_django_field, convert_field_to_string
from graphene_django.debug import DjangoDebug
from localized_fields.fields import LocalizedField

from .caluma_analytics import schema as analytics_schema
from .caluma_data_source import schema as data_source_schema
from .caluma_form import (
    historical_schema as form_historical_schema,
    schema as form_schema,
)
from .caluma_workflow import schema as workflow_schema

convert_django_field.register(LocalizedField, convert_field_to_string)

# The consolidated mutation is created procedurally here to avoid
# exporting it as `Mutation`, which can be confusing
_mutation = type(
    "Mutation",
    (
        form_schema.Mutation,
        workflow_schema.Mutation,
        analytics_schema.Mutation,
        graphene.ObjectType,
    ),
    {},
)

query_inherit_from = [
コード例 #5
0
ファイル: types.py プロジェクト: tim-fiola/nautobot
import graphene
from graphene_django import DjangoObjectType
from graphene_django.converter import convert_django_field, convert_field_to_string

from nautobot.dcim.graphql.types import InterfaceType
from nautobot.ipam import models, filters, fields
from nautobot.extras.graphql.types import TagType  # noqa: F401
from nautobot.virtualization.graphql.types import VMInterfaceType

# Register VarbinaryIPField to be converted to a string type
convert_django_field.register(fields.VarbinaryIPField)(convert_field_to_string)


class AggregateType(DjangoObjectType):
    """Graphql Type Object for Aggregate model."""

    prefix = graphene.String()

    class Meta:
        model = models.Aggregate
        filterset_class = filters.AggregateFilterSet


class AssignedObjectType(graphene.Union):
    """GraphQL type object for IPAddress's assigned_object field."""
    class Meta:
        types = (InterfaceType, VMInterfaceType)

    @classmethod
    def resolve_type(cls, instance, info):
        if type(instance).__name__ == "Interface":