Python graphql.ResolveInfo() Examples
The following are 30
code examples of graphql.ResolveInfo().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
graphql
, or try the search function
.
Example #1
Source File: query.py From lutece-backend with GNU General Public License v3.0 | 6 votes |
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))
Example #2
Source File: menus.py From wagtail-graphql with MIT License | 6 votes |
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
Example #3
Source File: mutation.py From lutece-backend with GNU General Public License v3.0 | 6 votes |
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())
Example #4
Source File: mutation.py From lutece-backend with GNU General Public License v3.0 | 6 votes |
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())
Example #5
Source File: type.py From lutece-backend with GNU General Public License v3.0 | 5 votes |
def resolve_mle(self, info: ResolveInfo) -> int: return Submission.objects.filter(user=self.user, result___result=JudgeResult.MLE.full).count()
Example #6
Source File: type.py From lutece-backend with GNU General Public License v3.0 | 5 votes |
def resolve_standard_submit(self, info: ResolveInfo) -> graphene.Int(): return self.submit
Example #7
Source File: type.py From lutece-backend with GNU General Public License v3.0 | 5 votes |
def resolve_ratio(self, info: ResolveInfo) -> float: ac = self.resolve_ac(info) _all = Submission.objects.filter(user=self.user).count() return ac / _all if _all else 0
Example #8
Source File: type.py From lutece-backend with GNU General Public License v3.0 | 5 votes |
def resolve_solve(self, info: ResolveInfo) -> List: return list(Solve.objects.filter(user=self.user).order_by('problem__pk'))
Example #9
Source File: type.py From lutece-backend with GNU General Public License v3.0 | 5 votes |
def resolve_data_count(self, info: ResolveInfo) -> graphene.Int: return DataService.get_cases_count(self.pk)
Example #10
Source File: type.py From lutece-backend with GNU General Public License v3.0 | 5 votes |
def resolve_standard_accept(self, info: ResolveInfo) -> graphene.Int(): return self.accept
Example #11
Source File: type.py From lutece-backend with GNU General Public License v3.0 | 5 votes |
def resolve_pk(self, info: ResolveInfo) -> graphene.ID(): return self.pk
Example #12
Source File: type.py From lutece-backend with GNU General Public License v3.0 | 5 votes |
def resolve_limitation(self, info: ResolveInfo) -> graphene.Field(AbstractLimiationType): return self.limitation
Example #13
Source File: type.py From lutece-backend with GNU General Public License v3.0 | 5 votes |
def resolve_samples(self, info: ResolveInfo) -> graphene.Field(ProblemSampleListType): result = ProblemSample.objects.filter(problem=self) return ProblemSampleListType(sample_list=result)
Example #14
Source File: query.py From lutece-backend with GNU General Public License v3.0 | 5 votes |
def resolve_problem(self: None, info: ResolveInfo, slug): problem_list = Problem.objects.all() privilege = info.context.user.has_perm('problem.view') if not privilege: problem_list = problem_list.filter(disable=False) return problem_list.get(slug=slug)
Example #15
Source File: query.py From lutece-backend with GNU General Public License v3.0 | 5 votes |
def resolve_problem_search(self: None, info: ResolveInfo, filter: str): problem_list = Problem.objects.all() if not info.context.user.has_perm('problem.view_all'): problem_list = problem_list.filter(disable=False) if filter: problem_list = problem_list.filter(Q(pk__contains=filter) | Q(title__icontains=filter)) else: problem_list = [] return ProblemListType(max_page=1, problem_list=problem_list[:5])
Example #16
Source File: query.py From lutece-backend with GNU General Public License v3.0 | 5 votes |
def resolve_problem_list(self: None, info: ResolveInfo, page: int, filter: str): problem_list = Problem.objects.all() privilege = info.context.user.has_perm('problem.view') if not privilege: problem_list = problem_list.filter(disable=False) if filter: problem_list = problem_list.filter(Q(pk__contains=filter) | Q(title__icontains=filter)) paginator = Paginator(problem_list, PER_PAGE_COUNT) return ProblemListType(max_page=paginator.num_pages, problem_list=paginator.get_page(page))
Example #17
Source File: query.py From lutece-backend with GNU General Public License v3.0 | 5 votes |
def resolve_user_list(self: None, info: ResolveInfo, page: int, filter: str) -> UserListType: request_usr = info.context.user user_list = User.objects.all().order_by('-solved') if not request_usr.has_perm('user.view'): user_list = user_list.filter(is_active=True, is_staff=False) if filter: user_list = user_list.filter(username__icontains=filter) paginator = Paginator(user_list, PER_PAGE_COUNT) return UserListType(max_page=paginator.num_pages, user_list=paginator.get_page(page))
Example #18
Source File: type.py From lutece-backend with GNU General Public License v3.0 | 5 votes |
def resolve_re(self, info: ResolveInfo) -> int: return Submission.objects.filter(user=self.user, result___result=JudgeResult.RE.full).count()
Example #19
Source File: type.py From lutece-backend with GNU General Public License v3.0 | 5 votes |
def resolve_wa(self, info: ResolveInfo) -> int: return Submission.objects.filter(user=self.user, result___result=JudgeResult.WA.full).count()
Example #20
Source File: type.py From lutece-backend with GNU General Public License v3.0 | 5 votes |
def resolve_ce(self, info: ResolveInfo) -> int: return Submission.objects.filter(user=self.user, result___result=JudgeResult.CE.full).count()
Example #21
Source File: type.py From lutece-backend with GNU General Public License v3.0 | 5 votes |
def resolve_tle(self, info: ResolveInfo) -> int: return Submission.objects.filter(user=self.user, result___result=JudgeResult.TLE.full).count()
Example #22
Source File: type.py From lutece-backend with GNU General Public License v3.0 | 5 votes |
def resolve_ac(self, info: ResolveInfo) -> int: return Submission.objects.filter(user=self.user, result___result=JudgeResult.AC.full).count()
Example #23
Source File: type.py From lutece-backend with GNU General Public License v3.0 | 5 votes |
def resolve_pk(self: Solve, info: ResolveInfo) -> int: return self.problem.pk
Example #24
Source File: mutation.py From lutece-backend with GNU General Public License v3.0 | 5 votes |
def mutate(self, info: ResolveInfo, **kwargs): update_form = UserAttachInfoUpdateForm(kwargs) if update_form.is_valid(): values = update_form.cleaned_data usr = info.context.user assign(usr.attach_info, **values) usr.attach_info.save() return UserAttachInfoUpdate(state=True) else: raise RuntimeError(update_form.errors.as_json())
Example #25
Source File: mutation.py From lutece-backend with GNU General Public License v3.0 | 5 votes |
def mutate(self, info: ResolveInfo, **kwargs): login_form = UserLoginForm(kwargs) if login_form.is_valid(): values = login_form.cleaned_data usr = User.objects.get(username=values.get('username')) token = get_token(usr) payload = get_payload(token, info.context) update_last_login(None, usr) return UserLogin(payload=payload, token=token, permission=list(usr.get_all_permissions()), user=usr) else: raise RuntimeError(login_form.errors.as_json())
Example #26
Source File: type.py From lutece-backend with GNU General Public License v3.0 | 5 votes |
def resolve_statistics(self, info: ResolveInfo) -> graphene.Field(UserSubmissionStatisticsType): return UserSubmissionStatisticsType(user=self)
Example #27
Source File: type.py From lutece-backend with GNU General Public License v3.0 | 5 votes |
def resolve_tried(self, info: ResolveInfo) -> graphene.Int: return self.tried
Example #28
Source File: type.py From lutece-backend with GNU General Public License v3.0 | 5 votes |
def resolve_solved(self, info: ResolveInfo) -> graphene.Int: return self.solved
Example #29
Source File: type.py From lutece-backend with GNU General Public License v3.0 | 5 votes |
def resolve_attach_info(self, info: ResolveInfo) -> graphene.Field(UserAttachInfoType): return self.attach_info
Example #30
Source File: type.py From lutece-backend with GNU General Public License v3.0 | 5 votes |
def resolve_last_login_date(self: User, info: ResolveInfo) -> datetime: return self.last_login or self.date_joined