Exemplo n.º 1
0
class Query(object):
    all_Doner = DjangoFilterConnectionField(DonerType)
    all_Donation = DjangoFilterConnectionField(DonationType)
        
    def resolve_all_Doner(self, info, **kwargs):
        return Doner.objects.all()
        
    def resolve_all_Donation(self, info, **kwargs):
        return Donation.objects.all()
Exemplo n.º 2
0
class Query(AbstractType):
    meetup = Node.Field(MeetupNode)
    all_meetups = DjangoFilterConnectionField(MeetupNode)
    attendee = Node.Field(AttendeeNode)
    all_attendees = DjangoFilterConnectionField(AttendeeNode)
    my_meetups = DjangoFilterConnectionField(MeetupNode)

    def resolve_my_meetups(self, args, context, info):
        if not context.user.is_authenticated():
            return MeetupModel.objects.none()
        else:
            return MeetupModel.objects.filter(attendee__user=context.user,
                                              **args)
Exemplo n.º 3
0
class Query(AbstractType):
    event = Node.Field(EventNode)
    all_events = DjangoFilterConnectionField(EventNode)
    event_attendee = Node.Field(EventAttendeeNode)
    all_event_attendees = DjangoFilterConnectionField(EventAttendeeNode)
    my_events = DjangoFilterConnectionField(EventNode)
    event_image = Node.Field(EventImageNode)
    all_event_images = DjangoFilterConnectionField(EventImageNode)

    def resolve_my_events(self, args, context, info):
        if not context.user.is_authenticated():
            return EventModel.objects.none()
        else:
            return EventModel.objects.filter(attendee__user=context.user,
                                             **args)
Exemplo n.º 4
0
class Query(graphene.ObjectType):
    ##Query all the records from the DB
    all_nims = graphene.List(NimsTmusType)

    def resolve_all_nims(self, info, **kwargs):
        return NimsTmus.objects.all()

    ##Connect to Relay Node to apply filter filds and pagination
    all_nimsrecs = DjangoFilterConnectionField(NimsTmusType)

    all_celloms = graphene.List(CellOMType)

    def resolve_all_celloms(self, info, **kwargs):
        return CellOM.objects.select_related('enb').all()

    all_enboms = graphene.List(EnbOMType)

    def resolve_all_enboms(self, info, **kwargs):
        return EnbOM.objects.all()

    cellom = graphene.Field(CellOMType, cellid=graphene.Int())

    def resolve_cellom(self, info, **kwargs):
        cellid = kwargs.get('cellid')
        if cellid is not None:
            return CellOM.objects.get(cellid=cellid)

    enbom = graphene.Field(EnbOMType, enb=graphene.Int())

    def resolve_enbom(self, info, **kwargs):
        enb = kwargs.get('enb')
        if enb is not None:
            return EnbOM.objects.get(enb=enb)
Exemplo n.º 5
0
class Query(graphene.ObjectType):
    film = relay.Node.Field(FilmType)
    filmAll = DjangoFilterConnectionField(FilmType)
    people = relay.Node.Field(PeopleType)
    planet = relay.Node.Field(PlanetType)
    species = relay.Node.Field(SpeciesType)
    transport = relay.Node.Field(TransportType)
    starship = relay.Node.Field(StarshipType)
    vehicle = relay.Node.Field(VehicleType)

    def resolve_film(self, info):
        return FilmModel.objects.all()

    def resolve_people(self, info):
        return PeopleModel.objects.all()

    def resolve_planet(self, info):
        return PlanetModel.objects.all()

    def resolve_species(self, info):
        return SpeciesModel.objects.all()

    def resolve_transport(self, info):
        return TransportModel.objects.all()

    def resolve_starship(self, info):
        return StarshipModel.objects.all()

    def resolve_vehicle(self, info):
        return VehicleModel.objects.all()
Exemplo n.º 6
0
class Query(AbstractType):
    group = Node.Field(GroupNode)
    group_image = Node.Field(GroupImageNode)
    all_group_images = DjangoFilterConnectionField(GroupImageNode)
    all_groups = DjangoFilterConnectionField(GroupNode)
    my_groups = DjangoFilterConnectionField(GroupNode)
    group_members = Node.Field(GroupMembersNode)
    all_group_members = DjangoFilterConnectionField(GroupMembersNode)

    def resolve_my_groups(self, args, context, info):
        if not context.user.is_authenticated():
            return Group.objects.none()
        else:
            return Group.objects.filter(groupmembers__user=context.user,
                                        groupmembers__active=True,
                                        **args)
Exemplo n.º 7
0
class Query(graphene.AbstractType):
    all_messages = DjangoFilterConnectionField(MessageType)
    all_customers = DjangoFilterConnectionField(CustomerType)
    current_user = graphene.Field(UserType)

    def resolve_all_messages(self, info, **kwargs):
        return models.Message.objects.all()

    def resolve_all_customers(self, info, **kwargs):
        return models.Customer.objects.all()

    def resolve_current_user(self, info, **kwargs):
        print("resolve_current_user")
        if not info.context.user.is_authenticated:
            print("resolve_current_user not authenticated")
            return None
        return info.context.user
Exemplo n.º 8
0
class Query(graphene.ObjectType):
    event_rsvps = DjangoFilterConnectionField(EventRSVPNode)

    def resolve_event_rsvps(self, info, **kwargs):
        return EventRSVP.objects \
            .order_by('event__date_time') \
            .filter(event__date_time__gt=timezone.now()) \
            .filter(**kwargs) \
            .select_related('event', 'event__artist')
Exemplo n.º 9
0
class Query(AbstractType):
    profile = Node.Field(ProfileNode)
    all_profiles = DjangoFilterConnectionField(ProfileNode)
    my_profile = graphene.Field(ProfileNode)
    profile_image = Node.Field(ProfileImageNode)
    all_profile_images = DjangoFilterConnectionField(ProfileImageNode)
    my_account = graphene.Field(AccountNode)

    def resolve_my_profile(self, args, context, info):
        if not context.user.is_authenticated():
            return ProfileModel.objects.none()
        else:
            return ProfileModel.objects.get(user=context.user)

    def resolve_my_account(self, args, context, info):
        if not context.user.is_authenticated():
            return User.objects.none()
        else:
            return context.user
Exemplo n.º 10
0
class Query(object):
    all_messages = graphene.List(MessageType)

    all_messages_filtered = DjangoFilterConnectionField(MessageType)

    def resolve_all_messages(self, info, **kwargs):
        return models.Message.objects.all()

    def resolve_all_messages_filtered(self, info, **kwargs):
        return models.Message.objects.all()
Exemplo n.º 11
0
class Query(graphene.AbstractType):
    clientes = DjangoFilterConnectionField(ClienteType)

    allclientes = graphene.List(ClienteType)

    def resolve_allclientes(self, info, **kwargs):
        return Cliente.objects.all()

    def resolve_clientes(self, info, **kwargs):
        return Cliente.objects.all()
Exemplo n.º 12
0
class Query(graphene.ObjectType):
    # hello query to check is_authenticated or not
    hello = graphene.String(name=graphene.String(default_value="stranger"))
    user_by_id = graphene.Field(UserType, id=graphene.Int())
    profile_by_id = graphene.Field(ProfileType, id=graphene.Int())
    users = DjangoFilterConnectionField(UserType)
    profiles = DjangoFilterConnectionField(ProfileType)

    # our Resolver method takes the GraphQL context (root, info) as well as
    # Argument (name) for the Field and returns data for the query Response
    def resolve_hello(root, info, name):
        is_authenticated = info.context.user.is_authenticated 
        return f'Hello {name} you are logged in : {is_authenticated}'

    def resolve_user_by_id(root, info, id):
        return User.objects.get(id=id)

    def resolve_profile_by_id(root, info, id):
        return Profile.objects.get(id=id)
Exemplo n.º 13
0
class Query(AbstractType):
    community = Node.Field(CommunityNode)
    all_communities = DjangoFilterConnectionField(CommunityNode)
    community_user_profile = Node.Field(CommunityUserProfileNode)
    all_community_user_profiles = DjangoFilterConnectionField(
        CommunityUserProfileNode)
    my_communities = DjangoFilterConnectionField(CommunityNode)
    post = Node.Field(PostNode)
    all_posts = DjangoFilterConnectionField(PostNode)
    post_image = Node.Field(PostImageNode)
    all_post_images = DjangoFilterConnectionField(PostImageNode)

    def resolve_my_communities(self, args, context, info):
        if not context.user.is_authenticated():
            return CommunityModel.objects.none()
        else:
            return CommunityModel.objects.filter(
                communityuserprofile__user=context.user,
                communityuserprofile__active=True,
                **args)
Exemplo n.º 14
0
class Query(graphene.ObjectType):
    post = graphene.Node.Field(PostType, username=graphene.String())
    all_posts = DjangoFilterConnectionField(
        PostType,
        id=graphene.ID(),
        username=graphene.String(required=True),
        q=graphene.String(),
        tags=graphene.String())
    all_tags = graphene.List(Tags, username=graphene.String())

    def resolve_current_user(self, args, context, info):
        if not context.user.is_authenticated():
            return None
        return context.user

    # This is weird. Passing args with graphene:
    # https://github.com/graphql-python/graphene/issues/378#issuecomment-352206929


#    @login_required

    def resolve_all_tags(self, info, **kwargs):
        info.context.args = dict(username=kwargs.get("username"))
        return [Tags()]

    # https://stackoverflow.com/a/39774434/41829
    def resolve_all_posts(self, info, **kwargs):
        username = kwargs.get('username')
        u = User.objects.get(username=username)
        searchterm = kwargs.get('q')
        tags = kwargs.get('tags')
        id = kwargs.get('id')
        if id:
            rid = from_global_id(id)[1]
            return (FeedPost.objects.all().filter(pk=rid))

        if tags:
            users_sources = FeedSource.objects.filter(user=u,
                                                      tags=tags,
                                                      show_on_frontpage=True)
        else:
            users_sources = FeedSource.objects.filter(user=u,
                                                      show_on_frontpage=True)
        if searchterm:
            queryset = FeedPost.objects.filter(
                feed__feedsource__in=users_sources).filter(
                    Q(title__icontains=searchterm)
                    | Q(content__icontains=searchterm)).annotate(
                        source_title=F('feed__feedsource__title'))
        else:
            queryset = FeedPost.objects.filter(
                feed__feedsource__in=users_sources).annotate(
                    source_title=F('feed__feedsource__title'))
        return queryset
Exemplo n.º 15
0
class Query(graphene.AbstractType):
    all_messages = DjangoFilterConnectionField(MessageType)

    message = graphene.Field(MessageType, id=graphene.ID())

    def resolve_all_messages(self, args, context, info):
        return models.Message.objects.all()

    def resolve_message(self, args, context, info):
        from graphql_relay.node.node import from_global_id
        pk = from_global_id(args.get('id'))[1]
        return models.Message.objects.get(pk=pk)
Exemplo n.º 16
0
class Queries(graphene.ObjectType):
    users = DjangoFilterConnectionField(UserQuery)
    user = graphene.Field(UserQuery)

    profile = graphene.Field(ProfileQuery)

    @staticmethod
    @login_required
    def resolve_user(info):
        return info.context.user

    @staticmethod
    @login_required
    def resolve_profile(info):
        return Profile.objects.get(user=info.context.user)
Exemplo n.º 17
0
class Query(graphene.ObjectType):
    id = graphene.Field(MessageType, input=UserInput())

    def resolve_message(self, info, input):
        id = input.get('id')

        # rid = from_global_id(args.get('id'))
        # rid is a tuple: ('MessageType', '1')
        # return models.Message.objects.get(pk=rid[1])
        return Message.objects.get(pk=id)

    all_messages = DjangoFilterConnectionField(MessageType)

    def resolve_all_messages(self, *args):
        return models.Message.objects.all()
Exemplo n.º 18
0
class Query(graphene.AbstractType):
    ''' The query schema for this app'''

    all_products = graphene.List(ProductType,
                                 available_only=graphene.Boolean())
    all_carts = DjangoFilterConnectionField(CartType)
    cart = CartNode.Field(CartType)

    def resolve_all_products(self, args, available_only=False, **kwargs):
        if available_only is True:
            return models.Product.objects.filter(inventory_count__gt=0)
        return models.Product.objects.all()

    def resolve_all_carts(self, args, **kwargs):
        return models.Cart.objects.all()
class Query(g.AbstractType):
    current_user = g.Field(UserType)
    message = g.Field(MessageType, id=g.ID())
    all_messages = DjangoFilterConnectionField(MessageType)

    def resolve_current_user(self, args, context, info):
        if not context.user.is_authenticated():
            return None
        return context.user

    def resolve_message(self, args, context, info):
        rid = from_global_id(args.get('id'))
        return Message.objects.get(pk=rid[1])

    def resolve_all_messages(self, args, context, info):
        return Message.objects.all()
Exemplo n.º 20
0
class Query(graphene.AbstractType):
    current_user = graphene.Field(UserType)

    def resolve_current_user(self, args, context, info):
        if not context.user.is_authenticated():
            return None
        return context.user

    message = graphene.Field(MessageType, id=graphene.ID())

    def resolve_message(self, args, context, info):
        rid = from_global_id(args.get('id'))
        #rid is a tuple: ('MessageType', '1')
        return models.Message.objects.get(pk=rid[1])

    #all_messages = graphene.List(MessageType)
    all_messages = DjangoFilterConnectionField(MessageType)

    def resolve_all_messages(self, args, context, info):
        return models.Message.objects.all()
Exemplo n.º 21
0
class Query(graphene.AbstractType):
    all_messages = DjangoFilterConnectionField(MessageType)
    current_user = graphene.Field(UserType,
                                  id=graphene.Int(),
                                  name=graphene.String())
    message = graphene.Field(MessageType,
                             id=graphene.ID(),
                             message=graphene.String())

    def resolve_all_messages(self, info, **kwargs):
        return models.Message.objects.all()

    def resolve_message(self, info, id):
        rid = from_global_id(id)
        return models.Message.objects.get(pk=rid[1])

    def resolve_current_user(self, info, **kwargs):
        context = info.context
        if not context.user.is_authenticated:
            return None
        return context.user
Exemplo n.º 22
0
class Query(object):
    all_tests = DjangoFilterConnectionField(TestType)

    def resolve_all_tests(self, info, **kwargs):
        return Test.objects.all()

    user_tests = DjangoFilterConnectionField(TestType)

    def resolve_user_tests(self, info, **kwargs):
        user = info.context.user
        if not user.is_authenticated:
            return Test.objects.none()
        user_tests_ids = list(
            TestResult.objects.filter(user=user).values_list('test',
                                                             flat=True))
        accessible_tests_ids = list(
            Test.objects.filter(
                status=Test.STATUS_OPEN,
                start_at__lte=timezone.now(),
                end_at__gte=timezone.now(),
                accessible_by=Test.ACCESSIBLE_BY_ANYONE).values_list(
                    'id', flat=True))
        test_ids = set(user_tests_ids + accessible_tests_ids)
        results = Test.objects.filter(
            pk__in=test_ids).order_by('-start_at').all()
        # TODO filter results here
        return results

    test = graphene.Field(TestType,
                          id=graphene.ID(),
                          uuid=graphene.String(),
                          name=graphene.String())

    def resolve_test(self, info, uuid):
        return Test.objects.get(uuid=uuid)

    test_result = graphene.Field(TestResultType,
                                 id=graphene.ID(),
                                 uuid=graphene.String(),
                                 user_id=graphene.String())

    def resolve_test_result(self, info, uuid, user_id=None):
        user = info.context.user
        if not user.is_authenticated:
            return None

        # Use User based on `user_id` if current user is_staff=True
        test_user = user
        if user_id and user.is_staff:
            try:
                test_user = User.objects.get(id=user_id)
            except User.DoesNotExist:
                return None

        result = TestResult.objects.filter(user=test_user, uuid=uuid).first()
        if result and not user.is_staff and user != result.user:
            return None
        return result

    test_questions = DjangoFilterConnectionField(QuestionType)

    def resolve_test_questions(self, info, **kwargs):
        return Question.objects.all()

    current_user = graphene.Field(UserType)

    def resolve_current_user(self, info, **kwargs):
        context = info.context
        if not context.user.is_authenticated:
            return None
        return context.user
Exemplo n.º 23
0
class UserQuery(graphene.ObjectType):
    user = graphene.relay.Node.Field(UserNode)
    users = DjangoFilterConnectionField(UserNode)
Exemplo n.º 24
0
class Query(graphene.AbstractType):
    all_messages = DjangoFilterConnectionField(MessageType)

    def resolve_all_messages(self, context, **kwargs):
        return models.Message.objects.all()
Exemplo n.º 25
0
class Query:
    problems = DjangoFilterConnectionField(types.ProblemNode)
Exemplo n.º 26
0
class Query(graphene.ObjectType):
    all_import = DjangoFilterConnectionField(
        AssetImportFactsNode, filterset_class=AssetImportFilter,
        description="Método que retorna os objetos do tipo importação")
    all_export = DjangoFilterConnectionField(
        AssetExportFactsNode, filterset_class=AssetExportFilter,
        description="Método que retorna os objetos do tipo exportação")
    all_tradeBlocs = DjangoFilterConnectionField(
        TradeBlocsType,
        description="Método que retorna os registros de blocos econômicos")
    all_country = DjangoFilterConnectionField(
        CountryType,
        description="Método que retorna os países registrados")
    all_federativeUnit = DjangoFilterConnectionField(
        FederativeUnitType,
        description="Método que retorna as unidades federativas registradas")
    all_transportation = DjangoFilterConnectionField(
        TransportationType,
        description="Método que retorna as vias de trasportação cadastradas")
    all_urf = DjangoFilterConnectionField(
        UrfType, description="Método que retorna as URFs registradas")
    all_ncm = DjangoFilterConnectionField(
        NCMType, description="Método que retorna os NCMs dos registros")
    all_cuci = DjangoFilterConnectionField(
        CUCIType,
        description="Método que retorna as nomenclaturas CUCI registradas")
    all_cgce = DjangoFilterConnectionField(
        CGCEType,
        description="Método que retorna as nomenclaturas CGCE registradas")
    all_sh = DjangoFilterConnectionField(
        SHType,
        description="Método que retorna as nomenclaturas SH registradas")
    aggregated_import_transportation = DjangoFilterConnectionField(
        Aggregated_Import, filterset_class=AssetImportFilter)
    aggregated_import_urf = DjangoFilterConnectionField(
        Aggregated_Import, filterset_class=AssetImportFilter)
    aggregated_import_date = DjangoFilterConnectionField(
        Aggregated_Import, filterset_class=AssetImportFilter)
    aggregated_import_country = DjangoFilterConnectionField(
        Aggregated_Import, filterset_class=AssetImportFilter)
    aggregated_import_trade_bloc = DjangoFilterConnectionField(
        Aggregated_Import, filterset_class=AssetImportFilter)
    aggregated_export_transportation = DjangoFilterConnectionField(
        Aggregated_Export, filterset_class=AssetExportFilter)
    aggregated_export_urf = DjangoFilterConnectionField(
        Aggregated_Export, filterset_class=AssetExportFilter)
    aggregated_export_date = DjangoFilterConnectionField(
        Aggregated_Export, filterset_class=AssetExportFilter)
    aggregated_export_country = DjangoFilterConnectionField(
        Aggregated_Export, filterset_class=AssetExportFilter)
    aggregated_export_trade_bloc = DjangoFilterConnectionField(
        Aggregated_Export, filterset_class=AssetExportFilter)

    def resolve_all_import(self, info, **kwargs):
        return AssetImportFacts.objects.all()

    def resolve_all_export(self, info, **kwargs):
        return AssetExportFacts.objects.all()

    def resolve_all_ncm(self, info, **kwargs):
        return NCM.objects.all()

    def resolve_all_tradeBlocs(self, info, **kwargs):
        return TradeBlocs.objects.all()

    def resolve_all_country(self, info, **kwargs):
        return Country.objects.all()

    def resolve_all_federativeUnit(self, info, **kwargs):
        return FederativeUnit.objects.all()

    def resolve_all_transportation(self, info, **kwargs):
        return Transportation.objects.all()

    def resolve_all_urf(self, info, **kwargs):
        return Urf.objects.all()

    def resolve_all_cuci(self, info, **kwargs):
        return CUCI.objects.all()

    def resolve_all_cgce(self, info, **kwargs):
        return CGCE.objects.all()

    def resolve_all_sh(self, info, **kwargs):
        return SH.objects.all()

    def resolve_aggregated_import_transportation(self, info, **kwargs):
        return list(AssetImportFacts.objects.raw(
            '''SELECT b.[id], a.[transportation_code], a.[transportation_name]
            FROM assets_Transportation a INNER JOIN assets_AssetImportFacts b
            ON a.[transportation_code]=b.[transportation_id]
            GROUP BY a.[transportation_name]'''))

    def resolve_aggregated_import_urf(self, info, **kwargs):
        return list(AssetImportFacts.objects.raw(
            '''SELECT b.[id], a.[urf_code], a.[urf_name]
            FROM assets_Urf a INNER JOIN assets_AssetImportFacts b
            ON a.[urf_code]=b.[urf_id]
            GROUP BY a.[urf_name]'''))

    def resolve_aggregated_import_date(self, info, **kwargs):
        return list(AssetImportFacts.objects.raw('''Select id, COUNT(date)
                                                FROM assets_AssetImportFacts
                                                GROUP BY date'''))

    def resolve_aggregated_import_country(self, info, **kwargs):
        return list(AssetImportFacts.objects.raw(
            '''SELECT b.[id], a.[id], a.[country_name_pt]
            FROM assets_Country a INNER JOIN assets_AssetImportFacts b
            ON a.[id]=b.[origin_country_id]
            GROUP BY a.[country_name_pt]'''))

    def resolve_aggregated_import_trade_bloc(self, info, **kwargs):
        return list(AssetImportFacts.objects.raw(
            '''SELECT c.[bloc_code], c.[bloc_name_pt], b.[origin_country_id],
                a.[id], a.[trade_bloc_id]
            FROM assets_AssetImportFacts b
            INNER JOIN assets_Country a
            ON a.[id]=b.[origin_country_id]
            INNER JOIN assets_TradeBlocs c
            ON c.[bloc_code]=a.[trade_bloc_id]
            GROUP BY c.[bloc_name_pt]'''))

    def resolve_aggregated_export_transportation(self, info, **kwargs):
        return list(AssetExportFacts.objects.raw(
            '''SELECT b.[id], a.[transportation_code], a.[transportation_name]
            FROM assets_Transportation a INNER JOIN assets_AssetExportFacts b
            ON a.[transportation_code]=b.[transportation_id]
            GROUP BY a.[transportation_name]'''))

    def resolve_aggregated_export_urf(self, info, **kwargs):
        return list(AssetExportFacts.objects.raw(
            '''SELECT b.[id], a.[urf_code], a.[urf_name]
            FROM assets_Urf a INNER JOIN assets_AssetExportFacts b
            ON a.[urf_code]=b.[urf_id]
            GROUP BY a.[urf_name]'''))

    def resolve_aggregated_export_date(self, info, **kwargs):
        return list(AssetExportFacts.objects.raw('''Select id, COUNT(date)
                                                FROM assets_AssetExportFacts
                                                GROUP BY date'''))

    def resolve_aggregated_export_country(self, info, **kwargs):
        return list(AssetExportFacts.objects.raw(
            '''SELECT b.[id], a.[id], a.[country_name_pt]
            FROM assets_Country a INNER JOIN assets_AssetExportFacts b
            ON a.[id]=b.[destination_country_id]
            GROUP BY a.[country_name_pt]'''))

    def resolve_aggregated_export_trade_bloc(self, info, **kwargs):
        return list(AssetExportFacts.objects.raw(
            '''SELECT c.[bloc_code], c.[bloc_name_pt], b.[destination_country_id],
                a.[id], a.[trade_bloc_id]
            FROM assets_AssetExportFacts b
            INNER JOIN assets_Country a
            ON a.[id]=b.[destination_country_id]
            INNER JOIN assets_TradeBlocs c
            ON c.[bloc_code]=a.[trade_bloc_id]
            GROUP BY c.[bloc_name_pt]'''))
Exemplo n.º 27
0
class Query(ObjectType):
    animal = relay.Node.Field(AnimalNode)
    all_animals = DjangoFilterConnectionField(AnimalNode)
    #custom filter passed as argument
    all_animals_customfilter = DjangoFilterConnectionField(
        AnimalNode, filterset_class=AnimalFilter)
Exemplo n.º 28
0
class Query(graphene.ObjectType):
    message = Node.Field(MessageType)
    all_messages = DjangoFilterConnectionField(MessageType)
Exemplo n.º 29
0
class Query(graphene.AbstractType):
    all_messages = DjangoFilterConnectionField(MessageType)

    def resolve_all_messages(self, info):
        return Message.objects.all()
Exemplo n.º 30
0
def Assemble(resource):
    class ObjectMeta:
        model = resource.model
        name = resource.model._meta.object_name
        fields = list(resource.gql_fields.keys())
        filter_fields = resource.filterset.filter_fields
        interfaces = (graphene.relay.Node,)
        convert_choices_to_enum = False

    resolvers = {}
    for name, _type in resource.property_map.items():

        def get_property(name):
            def property_resolver(obj, info):
                return getattr(obj, name)()

            return property_resolver

        resolvers[name] = _type(resolver=get_property(name))

    @classmethod
    def get_queryset(cls, queryset, info):
        qs, audit = resource.get_permitted_queryset(
            "list",
            user=(info.context.user.is_authenticated and info.context.user or None),
            qs=queryset,
        )
        return qs

    @classmethod
    def get_node(cls, info, id):
        obj, audit = resource.get_permitted_object(
            id,
            "detail",
            user=(info.context.user.is_authenticated and info.context.user or None),
        )
        return obj

    ObjectType = type(
        ObjectMeta.name,
        (DjangoObjectType,),
        {
            "Meta": ObjectMeta,
            **resolvers,
            "get_queryset": get_queryset,
            "get_node": get_node,
        },
    )

    class MutationMeta:
        serializer_class = resource.serializer_class.Assemble(resource, "id")
        model = resource.model
        name = "%sMutation" % resource.model._meta.object_name
        fields = list(resource.gql_fields.keys())
        convert_choices_to_enum = False

    Mutation = type(MutationMeta.name, (SerializerMutation,), {"Meta": MutationMeta})

    stub = "".join(
        part.capitalize() for part in resource.model._meta.verbose_name.split(" ")
    )
    plural = "".join(
        part.capitalize()
        for part in resource.model._meta.verbose_name_plural.split(" ")
    )

    list_view = "all_%s" % plural
    detail_view = stub

    gql_list = DjangoFilterConnectionField(ObjectType)
    gql_detail = graphene.relay.Node.Field(ObjectType)

    EasyQuery = type(
        "%sQuery" % ObjectMeta.name,
        (object,),
        {detail_view: gql_detail, list_view: gql_list},
    )

    EasyMutations = type(
        "%sMutations" % ObjectMeta.name,
        (object,),
        {"create_%s" % stub: Mutation.Field()},
    )

    return ObjectType, EasyQuery, None and EasyMutations