class ElementQueries(graphene.ObjectType): all_samples = DjangoFilterListField(SampleType, description='All Sample Filtered') all_experiments = DjangoFilterListField( ExperimentType, description='All Experiments Filtered') all_representations = DjangoFilterListField( RepresentationType, description='All Experiments Filtered')
class EvaluatorQueries(graphene.ObjectType): # Possible User list queries definitions #users = DjangoListObjectField(UserListType, description='All Users query') #users1 = DjangoFilterPaginateListField(UserType, pagination=LimitOffsetGraphqlPagination()) clusterdata = DjangoFilterListField(ClusterDataType) data = DjangoFilterListField(DataType) #users3 = DjangoListObjectField(UserListType, filterset_class=UserFilter, description='All Users query') # Defining a query for a single user # The DjangoObjectField have a ID type input field, that allow filter by id and is't necessary to define resolve function #user = DjangoObjectField(UserType, description='Single User query') # Another way to define a query to single user # # Exist two ways to define single or list user queries with DjangoSerializerType # user_retrieve1, user_list1 = UserModelType.QueryFields( # description='Some description message for both queries', # deprecation_reason='Some deprecation message for both queries' # ) # user_retrieve2 = UserModelType.RetrieveField( # description='Some description message for retrieve query', # deprecation_reason='Some deprecation message for retrieve query' # ) # user_list2 = UserModelType.ListField( # description='Some description message for list query', # deprecation_reason='Some deprecation message for list query'
class Query(ObjectType): characterClass = DjangoObjectField(CharacterClassType) ability = DjangoObjectField(AbilityType) character = DjangoObjectField(CharacterType) abilityUse = DjangoObjectField(AbilityUseType) gameSession = DjangoObjectField(GameSessionType) learnedAbility = DjangoObjectField(LearnedAbilityType) allCharacterClasses = DjangoFilterListField(CharacterClassType) allAbilities = DjangoFilterListField(AbilityType) allAbilityUses = DjangoFilterListField(AbilityUseType) allLearnedAbilities = DjangoFilterListField(LearnedAbilityType) allAbilitiesForClasses = List(AbilityType, classes=List(Int)) usersCharacters = List(CharacterType) learnedAbilities = List(AbilityType) def resolve_allAbilitiesForClasses(root, info, classes): return abilityService.getAllAbilitiesForClasses(classes) def resolve_usersCharacters(root, info): userId = info.context.user.id return characterService.getCharactersForUser(userId) def resolve_learnedAbilities(root, info): user = info.context.user gameData = gameDataService.getOrCreateGameData(user) return abilityService.getLearnedAbilitiesForCharacter( gameData.currentCharacter)
class DisasterCategoryType(DjangoObjectType): class Meta: model = DisasterCategory exclude_fields = ('events', ) filter_fields = {'name': ['icontains']} sub_categories = DjangoFilterListField(DisasterSubCategoryType)
class DisasterTypeObjectType(DjangoObjectType): class Meta: model = DisasterType exclude_fields = ('events', 'disaster_sub_category') filter_fields = {'name': ['icontains']} sub_types = DjangoFilterListField(DisasterSubObjectType)
def list_resolver(*args, **kwargs): qs = DjangoFilterListField.list_resolver(*args, **kwargs) if "ordering" in kwargs: ordering_fields = [ field.strip() for field in kwargs["ordering"].split(",") ] qs = qs.order_by(*ordering_fields) return qs
class Query(graphene.ObjectType): # These root queries return a single object, and require an ID param. hypatia_error = DjangoObjectField(ErrorType) problem = DjangoObjectField(ProblemType) assignment = DjangoObjectField(AssignmentType) teacher = DjangoObjectField(TeacherType) # These root queries return a list of objects, and can be filtered. hypatia_errors = DjangoFilterListField(ErrorType) problems = DjangoFilterListField(ProblemType) assignments = DjangoFilterListField(AssignmentType) teachers = DjangoFilterListField(TeacherType)
class EventType(DjangoObjectType): class Meta: model = Event exclude_fields = ('entries', ) event_type = graphene.Field(CrisisTypeGrapheneEnum) trigger = graphene.Field(TriggerType) trigger_sub_type = graphene.Field(TriggerSubObjectType) violence = graphene.Field(ViolenceType) violence_sub_type = graphene.Field(ViolenceSubObjectType) actor = graphene.Field(ActorType) countries = DjangoFilterListField(CountryType)
class Query: trigger_list = DjangoFilterListField(TriggerType) sub_type_trigger_list = DjangoFilterListField(TriggerSubObjectType) violence_list = DjangoFilterListField(ViolenceType) actor_list = DjangoFilterListField(ActorType) disaster_category_list = DjangoFilterListField(DisasterCategoryType) disaster_sub_category_list = DjangoFilterListField(DisasterSubCategoryType) disaster_type_list = DjangoFilterListField(DisasterTypeObjectType) disaster_sub_type_list = DjangoFilterListField(DisasterSubObjectType) event = DjangoObjectField(EventType) event_list = DjangoPaginatedListObjectField( EventListType, pagination=PageGraphqlPagination(page_size_query_param='pageSize'))
class Query(graphene.ObjectType): # Possible User list queries definitions all_users = DjangoListObjectField(UserListType, description=_('All Users query')) all_users1 = DjangoFilterPaginateListField( UserType, pagination=LimitOffsetGraphqlPagination()) all_users2 = DjangoFilterListField(UserType) all_users3 = DjangoListObjectField(UserListType, filterset_class=filtersets.UserFilter, description=_('All Users query')) # Defining a query for a single user # The DjangoObjectField have a ID type input field, that allow filter by id and is't necessary to define resolve function user = DjangoObjectField(UserType, description=_('Single User query')) # Another way to define a query to single user user1 = UserListType.RetrieveField( description=_('User List with pagination and filtering'))
class Queries(graphene.ObjectType): all_users = DjangoFilterListField(UserType) user = UserListType.RetrieveField( description="User List with pagination and filtering" )
class Query: chemotherapies = DjangoFilterListField(ChemotherapyType) complications = DjangoFilterListField(ComplicationType) consents = DjangoFilterListField(ConsentType) diagnoses = DjangoFilterListField(DiagnosisType) enrollments = DjangoFilterListField(EnrollmentType) immunotherapies = DjangoFilterListField(ImmunotherapyType) labtests = DjangoFilterListField(LabtestType) outcomes = DjangoFilterListField(OutcomeType) patients = DjangoFilterListField(PatientType) radiotherapies = DjangoFilterListField(RadiotherapyType) samples = DjangoFilterListField(SampleType) slides = DjangoFilterListField(SlideType) studies = DjangoFilterListField(StudyType) surgeries = DjangoFilterListField(SurgeryType) treatments = DjangoFilterListField(TreatmentType) tumourboards = DjangoFilterListField(TumourboardType)
class BioConverterQueries(graphene.ObjectType): all_bioseries = DjangoFilterListField(BioSeriesType) all_bioimages = DjangoFilterListField(BioImageType)
class Query(object): client = DjangoObjectField(ClientType) project = DjangoObjectField(ProjectType) project_list = DjangoFilterListField(ProjectListType) tag = DjangoObjectField(TagType)
class Query(object): taskgroup = graphene.Field(TaskGroupType) taskgroup_list = DjangoFilterListField(TaskGroupListType) task = DjangoObjectField(TaskType) task_user = graphene.List(TaskType) task_list = DjangoFilterListField(TaskListType) timeentry = DjangoObjectField(TimeEntryType) summary_weekly = graphene.Field(SummaryWeekType) summary_monthly = graphene.Field(SummaryMonthType) dashboard = graphene.Field(DashBoardType) def resolve_task_user(root, info): user = info.context.user if not user: return None else: return Task.objects.filter(user=user, ) def resolve_summary_weekly(root, info, **kwargs): date = datetime.date.today() start_week = date - datetime.timedelta(date.weekday()) end_week = start_week + datetime.timedelta(6) user = info.context.user if user.is_authenticated: # week total duration hours_week = TimeEntry.objects.filter( user=user, date__range=[ start_week, end_week ]).order_by().values('date').annotate( duration=F('end_time') - F('start_time'), ).aggregate( total_duration=Sum(F('duration')))['total_duration'] # day total_duration hours_day = TimeEntry.objects.filter( user=user, date__range=[ start_week, end_week ]).values('date').order_by('date').annotate( duration=Sum(F('end_time') - F('start_time'))).values( 'date', 'duration') return SummaryWeekType( total_hours_weekly=hours_week, total_hours_day=hours_day, ) else: return None def resolve_summary_monthly(root, info, **kwargs): date = datetime.date.today() last_day = date + relativedelta(day=1, months=+1, days=-1) first_day = date + relativedelta(day=1) user = info.context.user if user.is_authenticated: # monthly total_duration hours_monthly = TimeEntry.objects.filter( user=user, date__gte=first_day, date__lte=last_day, ).values('date').order_by().annotate( duration=F('end_time') - F('start_time'), ).aggregate( total_duration=Sum(F('duration')))['total_duration'] # day total_duration hours_day = TimeEntry.objects.filter( user=user, date__gte=first_day, date__lte=last_day, ).values('date').order_by('date').annotate( duration=Sum(F('end_time') - F('start_time'))).values( 'date', 'duration') return SummaryMonthType(total_hours_monthly=hours_monthly, total_hours_day=hours_day) else: return None def resolve_dashboard(root, info, **kwargs): return DashBoardType()