当前位置: 首页>>代码示例>>Python>>正文


Python graphql.ResolveInfo方法代码示例

本文整理汇总了Python中graphql.ResolveInfo方法的典型用法代码示例。如果您正苦于以下问题:Python graphql.ResolveInfo方法的具体用法?Python graphql.ResolveInfo怎么用?Python graphql.ResolveInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在graphql的用法示例。


在下文中一共展示了graphql.ResolveInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: MenusQueryMixin

# 需要导入模块: import graphql [as 别名]
# 或者: from graphql import ResolveInfo [as 别名]
def MenusQueryMixin():
    class Mixin:
        main_menu = graphene.List(Menu)
        secondary_menu = graphene.Field(SecondaryMenu,
                                        handle=graphene.String(required=True))
        secondary_menus = graphene.List(SecondaryMenu)

        def resolve_main_menu(self, _info: ResolveInfo) -> List[MainMenu]:
            return MainMenu.objects.all()

        def resolve_secondary_menus(self, _info: ResolveInfo) -> List[FlatMenu]:
            return FlatMenu.objects.all()

        def resolve_secondary_menu(self, _info, handle: ResolveInfo) -> FlatMenu:
            return FlatMenu.objects.filter(handle=handle).first()
    return Mixin 
开发者ID:tr11,项目名称:wagtail-graphql,代码行数:18,代码来源:menus.py

示例2: resolve_submissionList

# 需要导入模块: import graphql [as 别名]
# 或者: from graphql import ResolveInfo [as 别名]
def resolve_submissionList(self: None, info: ResolveInfo, page: int, **kwargs):
        pk = kwargs.get('pk')
        user = kwargs.get('user')
        problem = kwargs.get('problem')
        judge_status = kwargs.get('judge_status')
        language = kwargs.get('language')
        status_list = Submission.objects.all().order_by('-pk')
        # Only consider base class
        status_list = status_list.filter(submission_type=0)
        if not info.context.user.has_perm('problem.view'):
            status_list = status_list.filter(problem__disable=False)
        if not info.context.user.has_perm('user.view') or not info.context.user.has_perm('submission.view'):
            status_list = status_list.filter(user__is_staff=False)
        if pk:
            status_list = status_list.filter(pk=pk)
        if user:
            status_list = status_list.filter(user__username=user)
        if problem:
            status_list = status_list.filter(problem__slug=problem)
        if judge_status:
            status_list = status_list.filter(result___result=judge_status)
        if language:
            status_list = status_list.filter(_language=language)
        paginator = Paginator(status_list, PER_PAGE_COUNT)
        return SubmissionListType(max_page=paginator.num_pages, submission_list=paginator.get_page(page)) 
开发者ID:lutece-awesome,项目名称:lutece-backend,代码行数:27,代码来源:query.py

示例3: mutate

# 需要导入模块: import graphql [as 别名]
# 或者: from graphql import ResolveInfo [as 别名]
def mutate(self, info: ResolveInfo, **kwargs):
        signup_form = UserSignupForm(kwargs)
        if signup_form.is_valid():
            values = signup_form.cleaned_data
            usr = User()
            attach_info = AttachInfo()
            assign(usr, **values)
            assign(attach_info, **values)
            usr.set_password(usr.password)
            attach_info.save()
            usr.attach_info = attach_info
            usr.save()
            token = get_token(usr)
            payload = get_payload(token, info.context)
            return UserRegister(payload=payload, token=token, permission=list(usr.get_all_permissions()), user=usr)
        else:
            raise RuntimeError(signup_form.errors.as_json()) 
开发者ID:lutece-awesome,项目名称:lutece-backend,代码行数:19,代码来源:mutation.py

示例4: mutate

# 需要导入模块: import graphql [as 别名]
# 或者: from graphql import ResolveInfo [as 别名]
def mutate(self, info: ResolveInfo, **kwargs):
        form = UpdateProblemForm(kwargs)
        if form.is_valid():
            values = form.cleaned_data
            samples = loads(values.get('samples'))
            prob = Problem.objects.get(slug=values.get('slug'))
            assign(prob, **values)
            assign(prob.limitation, **values)
            prob.limitation.save()
            prob.save()
            ProblemSample.objects.filter(problem=prob).delete()
            for each in samples:
                ProblemSample(
                    input_content=each.get('inputContent'),
                    output_content=each.get('outputContent'),
                    problem=prob
                ).save()
            # To avoid the slug change, re-fetch the problem object
            return UpdateProblem(slug=prob.slug)
        else:
            raise RuntimeError(form.errors.as_json()) 
开发者ID:lutece-awesome,项目名称:lutece-backend,代码行数:23,代码来源:mutation.py

示例5: has_permission

# 需要导入模块: import graphql [as 别名]
# 或者: from graphql import ResolveInfo [as 别名]
def has_permission(self, info: ResolveInfo):
        return self.op_func(
            self.op1.has_permission(info), self.op2.has_permission(info)
        ) 
开发者ID:redzej,项目名称:graphene-permissions,代码行数:6,代码来源:permissions.py

示例6: has_node_permission

# 需要导入模块: import graphql [as 别名]
# 或者: from graphql import ResolveInfo [as 别名]
def has_node_permission(self, info: ResolveInfo, id: str) -> bool:
        return self.op_func(
            self.op1.has_node_permission(info, id),
            self.op2.has_node_permission(info, id),
        ) 
开发者ID:redzej,项目名称:graphene-permissions,代码行数:7,代码来源:permissions.py

示例7: has_mutation_permission

# 需要导入模块: import graphql [as 别名]
# 或者: from graphql import ResolveInfo [as 别名]
def has_mutation_permission(
        self, root: Any, info: ResolveInfo, input: dict
    ) -> bool:
        return self.op_func(
            self.op1.has_mutation_permission(root, info, input),
            self.op2.has_mutation_permission(root, info, input),
        ) 
开发者ID:redzej,项目名称:graphene-permissions,代码行数:9,代码来源:permissions.py

示例8: has_filter_permission

# 需要导入模块: import graphql [as 别名]
# 或者: from graphql import ResolveInfo [as 别名]
def has_filter_permission(self, info: ResolveInfo):
        return self.op_func(
            self.op1.has_filter_permission(info), self.op2.has_filter_permission(info)
        ) 
开发者ID:redzej,项目名称:graphene-permissions,代码行数:6,代码来源:permissions.py

示例9: get_node

# 需要导入模块: import graphql [as 别名]
# 或者: from graphql import ResolveInfo [as 别名]
def get_node(cls, info: ResolveInfo, id: str) -> Optional[Model]:
        if all((perm.has_node_permission(info, id) for perm in cls.permission_classes)):
            try:
                object_instance = cls._meta.model.objects.get(pk=id)  # type: ignore
            except cls._meta.model.DoesNotExist:  # type: ignore
                object_instance = None
            return object_instance
        else:
            return None 
开发者ID:redzej,项目名称:graphene-permissions,代码行数:11,代码来源:mixins.py

示例10: has_permission

# 需要导入模块: import graphql [as 别名]
# 或者: from graphql import ResolveInfo [as 别名]
def has_permission(cls, info: ResolveInfo) -> bool:
        return all(
            (perm.has_filter_permission(info) for perm in cls.permission_classes)
        ) 
开发者ID:redzej,项目名称:graphene-permissions,代码行数:6,代码来源:mixins.py

示例11: _aliases_from_info

# 需要导入模块: import graphql [as 别名]
# 或者: from graphql import ResolveInfo [as 别名]
def _aliases_from_info(
        cls, info: graphene.ResolveInfo
    ) -> 'Dict[str, _MapperEntity]':
        """
        Get cached aliases from graphene ResolveInfo object.

        Notes:
            Deprecated.

        Args:
            info: Graphene ResolveInfo object.

        Returns:
            Dictionary of model aliases.

        """
        context = info.context

        if isinstance(context, dict):
            filter_aliases = context[cls._filter_aliases]
        elif '__dict__' in context.__dir__():
            filter_aliases = getattr(context, cls._filter_aliases)
        else:
            raise RuntimeError(
                'Not supported with info.context type {}'.format(type(context))
            )

        return filter_aliases 
开发者ID:art1415926535,项目名称:graphene-sqlalchemy-filter,代码行数:30,代码来源:filters.py

示例12: filter

# 需要导入模块: import graphql [as 别名]
# 或者: from graphql import ResolveInfo [as 别名]
def filter(
        cls, info: ResolveInfo, query: Query, filters: 'FilterType'
    ) -> Query:
        """
        Return a new query instance with the args ANDed to the existing set.

        Args:
            info: GraphQL execution info.
            query: SQLAlchemy query.
            filters: Filters dictionary.

        Returns:
            Filtered query instance.

        """
        context = info.context

        if isinstance(context, dict):
            context[cls._filter_aliases] = {}
        elif '__dict__' in context.__dir__():
            setattr(context, cls._filter_aliases, {})
        else:
            msg = (
                'Graphene-SQLAlchemy-Filter: '
                'info.context has an unsupported type {}. '
                'Now cls.aliased(info, ...) is not supported. '
                'Allowed types: dict and object with __dict__ attribute.'
            ).format(type(context))
            warnings.warn(msg, RuntimeWarning)

        query, sqla_filters = cls._translate_many_filter(info, query, filters)
        if sqla_filters is not None:
            query = query.filter(*sqla_filters)

        return query 
开发者ID:art1415926535,项目名称:graphene-sqlalchemy-filter,代码行数:37,代码来源:filters.py

示例13: info

# 需要导入模块: import graphql [as 别名]
# 或者: from graphql import ResolveInfo [as 别名]
def info():
    db = create_engine('sqlite://')  # in-memory
    connection = db.engine.connect()
    transaction = connection.begin()
    Base.metadata.create_all(connection)

    session_factory = sessionmaker(bind=connection)
    session = scoped_session(session_factory)

    yield ResolveInfo(*[None] * 9, context={'session': session})

    transaction.rollback()
    connection.close()
    session.remove() 
开发者ID:art1415926535,项目名称:graphene-sqlalchemy-filter,代码行数:16,代码来源:conftest.py

示例14: query

# 需要导入模块: import graphql [as 别名]
# 或者: from graphql import ResolveInfo [as 别名]
def query(queryset, info, **options):
    """
    Automatically optimize queries.

    Arguments:
        - queryset (Django QuerySet object) - The queryset to be optimized
        - info (GraphQL ResolveInfo object) - This is passed by the graphene-django resolve methods
        - **options - optimization options/settings
            - disable_abort_only (boolean) - in case the objecttype contains any extra fields,
                                             then this will keep the "only" optimization enabled.
    """

    return QueryOptimizer(info, **options).optimize(queryset) 
开发者ID:tfoxy,项目名称:graphene-django-optimizer,代码行数:15,代码来源:query.py

示例15: _create_resolve_info

# 需要导入模块: import graphql [as 别名]
# 或者: from graphql import ResolveInfo [as 别名]
def _create_resolve_info(self, field_name, field_asts, return_type, parent_type):
        return ResolveInfo(
            field_name,
            field_asts,
            return_type,
            parent_type,
            schema=self.root_info.schema,
            fragments=self.root_info.fragments,
            root_value=self.root_info.root_value,
            operation=self.root_info.operation,
            variable_values=self.root_info.variable_values,
            context=self.root_info.context,
        ) 
开发者ID:tfoxy,项目名称:graphene-django-optimizer,代码行数:15,代码来源:query.py


注:本文中的graphql.ResolveInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。