class Query(ObjectType): """ QUery Class that recives querys likes api calls Args: ObjectType (graphene): [idetifed the odbject node for the call] """ one_film = relay.Node.Field(FilmType) specific_movie = DjangoFilterConnectionField(FilmType) all_films = relay.ConnectionField(FilmConnection) one_person = relay.Node.Field(PeopleType) specific_person = DjangoFilterConnectionField(PeopleType) all_person = relay.ConnectionField(PeopleConnection) one_planet = relay.Node.Field(PlanetType) specific_planet = DjangoFilterConnectionField(PlanetType) all_planet = relay.ConnectionField(PlanetConnection) def resolve_all_films(root, info, **kwargs): resolve_user(info) return Film.objects.all() def resolve_all_person(root, info, **kwargs): resolve_user(info) return People.objects.all() def resolve_all_planet(root, info, **kwargs): resolve_user(info) return Planet.objects.all() debug = Field(DjangoDebug, name='__debug')
class Query(graphene.ObjectType): total_remained_point = graphene.Int() points_issued = relay.ConnectionField(PointIssuedConnection) points_expired = relay.ConnectionField(PointIssuedConnection) points_consumed = relay.ConnectionField(PointConsumedConnection) def resolve_total_remained_point(self, info): user = info.context.user if user.is_anonymous: raise Exception("Not logged in!") now = timezone.now() result = PointIssued.objects.filter(remained_point__gt=0, expire_at__gte=now, user=user).aggregate( Sum("remained_point")) return result["remained_point__sum"] def resolve_points_issued(self, info, **kwargs): user = info.context.user if user.is_anonymous: raise Exception("Not logged in!") return PointIssued.objects.filter(user=user) def resolve_points_expired(self, info, **kwargs): user = info.context.user if user.is_anonymous: raise Exception("Not logged in!") now = timezone.now() return PointIssued.objects.filter(expire_at__lte=now, user=user) def resolve_points_consumed(self, info, **kwargs): user = info.context.user if user.is_anonymous: raise Exception("Not logged in!") return PointConsumed.objects.filter(user=user)
class Experiment(ObjectType): class Meta: interfaces = relay.Node, name = String(description='name of the directory') path = String(description="path to the experiment") parameters = Field(lambda: files.parameters.Parameters, ) metrics = Field(lambda: files.metrics.Metrics) def resolve_parameters(self, info): return files.parameters.get_parameters(self.parameters) def resolve_metrics(self, info): for m in find_metrics(self.id): return m return None directories = relay.ConnectionField(lambda: schema.directories.DirectoryConnection) files = relay.ConnectionField(lambda: schema.files.FileConnection) def resolve_directories(self, info, **kwargs): from ml_dash.config import Args root_dir = join(Args.logdir, self.id[1:]) return [schema.directories.get_directory(join(self.id, _)) for _ in listdir(root_dir) if not isfile(join(root_dir, _))] def resolve_files(self, info, **kwargs): from ml_dash.config import Args root_dir = join(Args.logdir, self.id[1:]) return [schema.files.File(id=join(self.id, _), name=_) for _ in listdir(root_dir) if isfile(join(root_dir, _))] @classmethod def get_node(cls, info, id): return Experiment(id=id)
class Query(graphene.ObjectType): node = relay.Node.Field() ideas = relay.ConnectionField( Idea, filter=graphene.String() ) account = graphene.Field(Person) actions = relay.ConnectionField( Action, process_id=graphene.String(), node_ids=graphene.List(graphene.String), context=graphene.String() ) root = graphene.Field(Root) def resolve_ideas(self, args, context, info): # pylint: disable=W0613 oids = get_entities([Iidea], ['published'], args, info) return ResolverLazyList(oids, Idea) def resolve_account(self, args, context, info): # pylint: disable=W0613 return context.user def resolve_actions(self, args, context, info): # pylint: disable=W0613 return get_actions(get_context(args.get('context', '')), context, args) def resolve_root(self, args, context, info): # pylint: disable=W0613 return context.root
class Query(graphene.ObjectType): messages = relay.ConnectionField(MessageConnection, dialogue_id=graphene.String()) me = graphene.Field(UserNode) users = relay.ConnectionField(UserConnection) my_dialogues = relay.ConnectionField(DialogueConnection) @login_required @is_owner @staticmethod def resolve_messages(self, info, dialogue_id, **kwargs): dialogue = Dialogue.objects.get(id=from_global_id(dialogue_id)[1]) messages = Message.objects.filter(dialogue=dialogue) return messages @login_required @staticmethod def resolve_me(self, info, **kwargs): return info.context.user @staticmethod def resolve_users(self, info, **kwargs): return User.objects.all() @login_required @staticmethod def resolve_my_dialogues(self, info, **kwargs): user = info.context.user dialogues = Dialogue.objects.filter(Q(user1=user) | Q(user2=user)) return dialogues
class Project(ObjectType): class Meta: interfaces = relay.Node, name = String(description='name of the project') # description = String(description='string serialized data') # experiments = List(lambda: schema.Experiments) experiments = relay.ConnectionField( lambda: schema.experiments.ExperimentConnection) def resolve_experiments(self, info, before=None, after=None, first=None, last=None): # todo: add support for before after and last if first is not None: return schema.experiments.find_experiments(cwd=self.id, stop=first) return schema.experiments.find_experiments(cwd=self.id) directories = relay.ConnectionField( lambda: schema.directories.DirectoryConnection) def resolve_directories(self, info, before=None, after=None, first=None, last=None): from ml_dash.config import Args root_dir = join(Args.logdir, self.id[1:]) return [ schema.Directory(id=join(self.id, _), name=_) for _ in listdir(root_dir) if not isfile(join(root_dir, _)) ] files = relay.ConnectionField(lambda: schema.files.FileConnection) def resolve_files(self, info, before=None, after=None, first=None, last=None): from ml_dash.config import Args root_dir = join(Args.logdir, self.id[1:]) return [ schema.Directory(id=join(self.id, _), name=_) for _ in listdir(root_dir) if isfile(join(root_dir, _)) ] @classmethod def get_node(cls, info, id): return get_project(id)
class Project(graphene.ObjectType): id = graphene.ID(required=True) name = graphene.String() access = graphene.String() entityName = graphene.String() description = graphene.String() createdAt = graphene.String() summaryMetrics = graphene.String() views = graphene.JSONString() runCount = graphene.Int() bucketCount = graphene.Int() requestSubscribe = graphene.Boolean() runs = relay.ConnectionField( RunConnection, entityName=graphene.String(), names=graphene.List(graphene.String), jobKey=graphene.String(), order=graphene.String()) buckets = relay.ConnectionField( BucketConnection, entityName=graphene.String(), names=graphene.List(graphene.String), jobKey=graphene.String(), order=graphene.String()) run = graphene.Field(Run, name=graphene.String()) bucket = graphene.Field(BucketType, name=graphene.String()) sweeps = relay.ConnectionField(SweepConnectionType) def resolve_description(self, info, **args): return settings.get_project("description") def resolve_sweeps(self, info, **args): return [] def resolve_run(self, info, **args): return find_run(args["name"]) def resolve_bucket(self, info, **args): return find_run(args["name"]) def resolve_entityName(self, info, **args): return "board" def resolve_runs(self, info, **args): return data["Runs"] def resolve_buckets(self, info, **args): return data["Runs"] def resolve_id(self, info, **args): return "default" def resolve_name(self, info, **args): return "default" def resolve_summaryMetrics(self, info, **args): return "{}" def resolve_views(self, info, **args): return settings.get_project("views")
class Query(graphene.ObjectType): users = relay.ConnectionField(UserPublicConnection) protected_users = relay.ConnectionField(UserConnection) def resolve_users(self, info, **kwargs): return models.User.objects.all() @superuser_required def resolve_protected_users(self, info, **kwargs): return models.User.objects.all()
class Directory(ObjectType): class Meta: interfaces = relay.Node, name = String(description='name of the directory') path = String(description='absolute path of the directory') readme = Field(lambda: schema.files.File) def resolve_readme(self, info, *args, **kwargs): # note: keep it simple, just use README for now. readmes = schema.files.find_files_by_query(cwd=self.id, query="README.md") return readmes[0] if readmes else None # deprecate this dash_configs = relay.ConnectionField(lambda: schema.files.FileConnection) def resolve_dash_configs(self, info, *args, **kwargs): return schema.files.find_files_by_query(cwd=self.id, query="*.dashcfg") charts = relay.ConnectionField(lambda: schema.files.FileConnection) def resolve_charts(self, info, *args, **kwargs): return schema.files.find_files_by_query(cwd=self.id, query="**/*.chart.yml") experiments = relay.ConnectionField(lambda: schema.experiments.ExperimentConnection) def resolve_experiments(self, info, first=None, **kwargs): if first is not None: return schema.experiments.find_experiments(cwd=self.id, stop=first) return schema.experiments.find_experiments(cwd=self.id) directories = relay.ConnectionField(lambda: schema.directories.DirectoryConnection) def resolve_directories(self, info, **kwargs): from ml_dash.config import Args root_dir = join(Args.logdir, self.id[1:]) return [get_directory(join(self.id, _)) for _ in listdir(root_dir) if not isfile(join(root_dir, _))] files = relay.ConnectionField(lambda: schema.files.FileConnection) def resolve_files(self, info, **kwargs): from ml_dash.config import Args root_dir = join(Args.logdir, self.id[1:]) return [schema.files.File(id=join(self.id, _), name=_) for _ in listdir(root_dir) if isfile(join(root_dir, _))] @classmethod def get_node(cls, info, id): return get_directory(id)
class Query(graphene.ObjectType): alarms = relay.ConnectionField(AlarmConnection) alarms_not_checked = relay.ConnectionField(AlarmConnection) def resolve_alarms(self, info, **kwargs): user = info.context.user if user.is_anonymous: raise Exception("Not logged in!") return Alarm.objects.filter(user=user) def resolve_alarms_not_checked(self, info, **kwargs): user = info.context.user if user.is_anonymous: raise Exception("Not logged in!") return Alarm.objects.filter(user=user, is_checked=False)
class Experiment(ObjectType): class Meta: interfaces = relay.Node, name = String(description='name of the directory') path = String(description="path to the experiment") readme = Field(lambda: schema.files.File) parameters = Field(lambda: files.parameters.Parameters, ) metrics = Field(lambda: files.metrics.Metrics) def resolve_readme(self, info, *args, **kwargs): # note: keep it simple, just use README for now. readmes = schema.files.find_files_by_query(cwd=self.id, query="README.md") return readmes[0] if readmes else None def resolve_parameters(self, info): # note: when called with wrong path, parasitically # slow b/c list all metric files. for p in find_parameters(self.id): return p return None def resolve_metrics(self, info): # note: when called with wrong path, parasitically # slow b/c list all metric files. for m in find_metrics(self.id): return m return None directories = relay.ConnectionField(lambda: schema.directories.DirectoryConnection) files = relay.ConnectionField(lambda: schema.files.FileConnection) def resolve_directories(self, info, **kwargs): from ml_dash.config import Args root_dir = join(Args.logdir, self.id[1:]) return [schema.directories.get_directory(join(self.id, _)) for _ in listdir(root_dir) if not isfile(join(root_dir, _))] def resolve_files(self, info, **kwargs): from ml_dash.config import Args root_dir = join(Args.logdir, self.id[1:]) return [schema.files.File(id=join(self.id, _), name=_) for _ in listdir(root_dir) if isfile(join(root_dir, _))] @classmethod def get_node(cls, info, id): return get_experiment(id)
class Debatable(graphene.AbstractType): channel = graphene.Field(lambda: Channel) comments = relay.ConnectionField( lambda: Comment, filter=graphene.String()) len_comments = graphene.Int() def resolve_channel(self, args, context, info): if not hasattr(self, 'get_channel'): return None return self.get_channel(getattr(context, 'user', None)) def resolve_comments(self, args, context, info): if not hasattr(self, 'get_channel'): return [] channel = self.get_channel(getattr(context, 'user', None)) return ResolverLazyList( get_all_comments(channel, args), Comment) def resolve_len_comments(self, args, context, info): if not hasattr(self, 'get_channel'): return 0 channel = self.get_channel(getattr(context, 'user', None)) return channel.len_comments if channel else 0
class Query(graphene.ObjectType): user = graphene.Field(MyUsers, user_id=graphene.ID(required=True)) user_profile = graphene.Field(MyUserProfiles, user_id=graphene.String(required=True)) # user_profiles = DjangoListField(MyUserProfiles) # user_profiles = graphene.List(MyUserProfiles) # Pagination # user_profiles = relay.ConnectionField(MyUserConnection) test_user = relay.ConnectionField(MyUserConnection) is_authenticated = graphene.Boolean() def resolve_users(self, info): return USER_MODEL.objects.all() def resolve_user(self, info, user_id): return USER_MODEL.objects.get(id=user_id) def resolve_user_profiles(self, info): return MyUserProfile.objects.prefetch_related('myuser').all() def resolve_user_profile(self, info, user_id): return MyUserProfile.objects.prefetch_related('myuser').get(pk=user_id) def resolve_is_authenticated(self, info): return info.context.user.is_authenticated
class NodeEdges(graphene.ObjectType): class Meta: interfaces = (relay.Node, ) source = relay.ConnectionField(NodeConnection, description="A node of the sucrce") target = relay.ConnectionField(NodeConnection, description="A node of the target") weight = graphene.Float() rank = graphene.Int() def resolve_source(self, info, **args): return [get_label(label) for label in self.source] def resolve_target(self, info, **args): return [get_label(label) for label in self.target]
class LegislatorType(DjangoObjectType): class Meta: model = Legislator filter_fields = { 'name': ['exact', 'icontains', 'istartswith'], 'chamber': ['exact', 'icontains'], 'district': ['exact'], 'party': ['exact', 'icontains'], } order_fields = ('name', 'name') interfaces = (relay.Node, ) connection_class = ExtendedConnection pk = graphene.Int() def resolve_pk(self, info, **kwargs): return self.id contributions = relay.ConnectionField(ContributionssummaryTypeConnection) def resolve_contributions(self, info, **kwargs): try: id_map = LegislatorIdMap.objects.get( openstates_leg_id=self.openstates_leg_id) filer = Filer.objects.filter(id=id_map.tpj_filer_id).first() return Contributionsummary.objects.select_related('donor').filter( filer=filer.id).order_by('-cycle_total')[:25] except: return []
class OpcServerSchema(graphene.ObjectType): class Meta: interfaces = (relay.Node, ) server_id = graphene.Int() name = graphene.String() runtime_id = graphene.String() url = graphene.String() tags = relay.ConnectionField(TagSchemaConnection, description="Tags on the server.") def resolve_tags(self, info): opc_servers = info.context.get('opc_servers') tags = [] print("Resolving Tags") tag_schema = TagSchema(namespace_index=2, node_class='test2', variant_type='test2', node_id='test2') tags.append(tag_schema) return tags @classmethod def get_node(cls, info): return get_opc_server(id)
class Schedule(relay.Node, Node): dates_str = graphene.String() calendar = graphene.String() venue = relay.ConnectionField(Venue) price = graphene.String() ticket_type = graphene.String() ticketing_url = graphene.String() next_date = Date() is_expired = graphene.Boolean() def resolve_venue(self, args, info): return [Venue(_root=self.venue)] def resolve_ticketing_url(self, args, info): return self.get_ticketing_url() def resolve_dates_str(self, args, info): return self.dates def resolve_calendar(self, args, info): """cost: 50ms for 50 events """ return get_schedules_ical_calendar( [self], pytz.timezone('Europe/Paris')) def resolve_next_date(self, args, info): """cost: 10ms for 50 events """ return resolve_next_date(self, args, info) def resolve_is_expired(self, args, info): return 'archived' in self.state
class DirectoryContents(G.ObjectType): class Meta: interfaces = (Contents, R.Node) content = R.ConnectionField(lambda: ContentsConnection) resolve_content = RESOLVE_CONTENT
class Comment(Node, graphene.ObjectType): """Nova-Ideo ideas.""" class Meta(object): interfaces = (relay.Node, IEntity) created_at = graphene.String() state = graphene.List(graphene.String) text = graphene.String() author = graphene.Field(Person) attached_files = graphene.List(File) urls = graphene.List(Url) actions = graphene.List( Action, process_id=graphene.String(), node_ids=graphene.List(graphene.String)) oid = graphene.String() comments = relay.ConnectionField( lambda: Comment, filter=graphene.String()) len_comments = graphene.Int() root_oid = graphene.String() channel = graphene.Field(lambda: Channel) @classmethod def is_type_of(cls, root, context, info): # pylint: disable=W0613 if isinstance(root, cls): return True return isinstance(root, SDComment) def resolve_created_at(self, args, context, info): return self.created_at.isoformat() def resolve_text(self, args, context, info): return self.comment def resolve_urls(self, args, context, info): # pylint: disable=W0613 return [Url(**url) for url in getattr(self, 'urls', {}).values()] def resolve_oid(self, args, context, info): # pylint: disable=W0613 return get_oid(self, None) def resolve_attached_files(self, args, context, info): # pylint: disable=W0613 return getattr(self, 'files', []) def resolve_comments(self, args, context, info): # pylint: disable=W0613 return ResolverLazyList( get_all_comments(self, args), Comment) def resolve_len_comments(self, args, context, info): return self.len_comments def resolve_actions(self, args, context, info): # pylint: disable=W0613 return get_actions(self, context, args) def resolve_root_oid(self, args, context, info): # pylint: disable=W0613 return get_oid(self.channel.get_subject(getattr(context, 'user', None)), None)
class AddEvidence(graphene.Mutation): class Arguments: point_data = PointInput(required=True) parent = graphene.Field(Point) point = graphene.Field(Point) newEdges = relay.ConnectionField(SubPointConnection) def resolve_newEdges(self, info, **args): return [self.point] def mutate(self, info, point_data): oldPoint, oldPointRoot = PointModel.getCurrentByUrl( point_data.parentURL) newPoint, newLinkPoint = PointModel.addSupportingPoint( oldPointRoot=oldPointRoot, title=point_data.title, content=point_data.content, summaryText=point_data.summaryText, user=info.context.current_user, linkType=point_data.linkType, imageURL=point_data.imageURL, imageAuthor=point_data.imageAuthor, imageDescription=point_data.imageDescription, sourcesURLs=point_data.sourceURLs, sourcesNames=point_data.sourceNames) # these two are in service of the SubPointConnection logic - we should find a way to DRY this up newLinkPoint.parent = newPoint newLinkPoint.link_type = point_data.linkType return AddEvidence(point=newLinkPoint, parent=newPoint)
class RankModeType(MongoengineObjectType): class Meta: model = RankModeModel interfaces = (RankModeNode, ) ranking = relay.ConnectionField(RankConnection, page=Int(), count_for_rows=Int(), order=List(String)) @classmethod def resolve_ranking(cls, root, info, **input) -> RankConnection: # Pagination page = input.get("page") if "page" in input else 1 count_for_rows = input.get( "count_for_rows") if "count_for_rows" in input else 10 order = input.get("order") if "order" in input else list() skip = (page - 1) * count_for_rows # Mongo Object Parse to Edge conn_type = cls.ranking.type node_name = conn_type._meta.node._meta.name datas = RankModel.objects(mode=root.mode).all() nodes = datas.order_by(*order).skip(skip).limit(count_for_rows) edges = [ conn_type.Edge(node=node, cursor=base64(f"{ node_name }:{ str(node.id) }")) for node in nodes ] # Create new RankConnection Object return conn_type(edges=edges, page_info=relay.PageInfo(has_previous_page=True, has_next_page=True), total_count=len(datas))
class UrlQuery: '''All url read queries.''' urls = relay.ConnectionField(UrlConnection) url = Field(UrlErrorUnion, shortcode=String()) def resolve_urls(self, info: ResolveInfo, **kwargs) -> QuerySet: ''' retreive all urls. :param info :type ResolveInfo :return :type QuerySet ''' return Url.objects.all() def resolve_url(self, info: ResolveInfo, shortcode: str, **kwargs): ''' retreive url by pk (shortcode) :param info :type ResolveInfo :param shortcode :type str :return :type Url ''' try: url = Url.objects.get(shortcode=shortcode) url.increment_redirect_count() return url except ObjectDoesNotExist: return HTTP_NOT_FOUND
class User(SQLAlchemyObjectType): custom_sets = relay.ConnectionField(graphene.NonNull(CustomSetConnection), search=graphene.Argument( graphene.String)) def resolve_custom_sets(self, info, **kwargs): search = kwargs.get("search") query = (db.session.query(ModelCustomSet).filter_by( owner_id=self.uuid).order_by(ModelCustomSet.last_modified.desc())) if search: search = search.strip() query = query.filter( func.upper(ModelCustomSet.name).contains( func.upper(search.strip()))) return query.all() def resolve_email(self, info, **kwargs): if self.uuid != current_user.get_id(): raise GraphQLError( _("You are not authorized to make this request.")) return self.email class Meta: model = ModelUserAccount interfaces = (GlobalNode, ) only_fields = ("id", "username", "email", "custom_sets", "verified")
class Query(graphene.ObjectType): companies = relay.ConnectionField(CompanyConection) all_companies = graphene.List(CompanyType) company_by_tick = graphene.Field(CompanyType, ticks=graphene.String(required=True)) company_by_name = graphene.Field(CompanyType, name=graphene.String(required=True)) # For Pagination def resolve_companies(self, info, **kwargs): # print(kwargs) print(Company.objects.all()[0].pe_ratio) return Company.objects.all() def resolve_all_companies(self, info): return Company.objects.all() def resolve_company_by_tick(self, info, ticks): try: return None except Company.DoesNotExist: return None def resolve_company_by_name(self, info, name): try: return Company.objects.get(name=name); except Company.DoesNotExist: return None
class Package(SQLAlchemyObjectType): class Meta: model = PackageModel interfaces = (relay.Node, ) exclude_fields = ['owner_org', 'private'] ckan_id = graphene.String() groups = relay.ConnectionField(GroupConnection) organization = graphene.Field(Group) def resolve_ckan_id(self, info): return self.id def resolve_groups(self, info): query = Group.get_query(info) query = query.join(MemberModel, MemberModel.group_id == GroupModel.id and MemberModel.table_name == 'package')\ .join(PackageModel, PackageModel.id == MemberModel.table_id)\ .filter(MemberModel.state == 'active')\ .filter(GroupModel.type == 'group') query = query.filter(MemberModel.table_id == self.id) return query.all() def resolve_organization(self, info): query = Group.get_query(info) query = query.filter(GroupModel.id == self.owner_org) return query.first()
class Query(MeQuery, graphene.ObjectType): courses = relay.ConnectionField(CourseConnection, resolver=CourseType.resolve_all) offers = DjangoFilterConnectionField(OfferType) class_times = DjangoFilterConnectionField(ClassTimeType) my_class_times = DjangoFilterConnectionField(ClassTimeType) enrollments = DjangoFilterConnectionField(EnrollmentType) matching_offers = DjangoFilterConnectionField(OfferType) student_requests = DjangoFilterConnectionField(StudentRequestType) @staticmethod def resolve_enrollments(self, info, **kwargs): enrollment_resolver.resolve_enrollments(self, info, **kwargs) @staticmethod def resolve_my_class_times(self, info, **kwargs): class_time_resolver.resolve_my_class_times(self, info, **kwargs) @staticmethod def resolve_offers(self, info, **kwargs): offer_resolver.resolve_offers(self, info, **kwargs) @staticmethod def resolve_matching_offers(self, info, **kwargs): offer_resolver.resolve_matching_offers(self, info, **kwargs) @staticmethod def resolve_class_times(self, info, **kwargs): class_time_resolver.resolve_class_times(self, info, **kwargs) @staticmethod def resolve_student_requests(self, info, **kwargs): student_request_resolver.resolve_student_requests(self, info, **kwargs)
class Venue(relay.Node, Node): title = graphene.String() description = graphene.String() address = relay.ConnectionField(Address) def resolve_address(self, args, info): addresses = getattr(self, 'addresses', []) address = addresses[0] if addresses else {} addressStr = self.address_str(address) title = address.get('title', '') addressDetail = address.get('address', None) country = address.get('country', None) city = address.get('city', None) zipcode = address.get('zipcode', None) department = address.get('department', None) geoLocation = address.get('coordinates', None) return [Address( title=title, address=addressDetail, country=country, city=city, zipcode=zipcode, department=department, addressStr=addressStr, geoLocation=geoLocation)]
class TextsQueries(graphene.ObjectType): texts = FilterableConnectionField(TextConnection, slug=graphene.String()) texts_search = relay.ConnectionField(SearchIndexedTextConnection, query=graphene.String()) collections = FilterableConnectionField(CollectionConnection, slug=graphene.String()) text_annotations = relay.ConnectionField(TextAnnotationConnection) def resolve_text_annotations(root, info): return models.session.query(models.TextLabel).all() def resolve_texts_search(root, info, query): return models.Text.search(query)
class AutomationTaskInterface(graphene.Interface): """An AutomationTask in the NSHM process""" result = EventResult() state = EventState() created = graphene.DateTime(description="The time the event was created") duration = graphene.Float( description="the final duration of the event in seconds") parents = relay.ConnectionField( 'graphql_api.schema.task_task_relation.TaskTaskRelationConnection', description="parent task(s) of this task") arguments = graphene.List( KeyValuePair, required=False, description= "input arguments for the rupture generation task, as a list of Key Value pairs." ) environment = graphene.List( KeyValuePair, required=False, description= "execution environment details, as a list of Key Value pairs.") metrics = graphene.List( KeyValuePair, required=False, description= "result metrics from the task, as a list of Key Value pairs.")
class Query(ObjectType): fundingRound = relay.NodeField(FundingRoundNode) allFundingRounds = DjangoFilterConnectionField(FundingRoundNode) object = relay.NodeField(ObjectNode) allObjects = DjangoFilterConnectionField(ObjectNode) relationship = relay.NodeField(RelationshipNode) allRelationships = DjangoFilterConnectionField(RelationshipNode) degree = relay.NodeField(DegreeNode) allDegrees = DjangoFilterConnectionField(DegreeNode) acquisition = relay.NodeField(AcquisitionNode) allAcquisitions = DjangoFilterConnectionField(AcquisitionNode) fund = relay.NodeField(FundNode) allFunds = DjangoFilterConnectionField(FundNode) investment = relay.NodeField(InvestmentNode) allInvestments = DjangoFilterConnectionField(InvestmentNode) ipo = relay.NodeField(IpoNode) allIpos = DjangoFilterConnectionField(IpoNode) milestone = relay.NodeField(MilestoneNode) allMilestones = DjangoFilterConnectionField(MilestoneNode) office = relay.NodeField(OfficeNode) allOffices = DjangoFilterConnectionField(OfficeNode) people = relay.NodeField(PeopleNode) allPeople = DjangoFilterConnectionField(PeopleNode) myObjects = relay.ConnectionField(ObjectNode, \ description='Get objects by params.', \ limit=graphene.Int(), \ school=graphene.String(), \ isInvestor=graphene.Boolean() ) def resolve_myObjects(self, args, info): limit = args.get('limit') school = args.get('school') if (school is not None) and (school != ''): ret = [] len = 0 degrees = CbDegrees.objects.filter(institution=school) for degree in degrees: if len == limit: break ret.append(degree.object) len += 1 return ret return CbObjects.objects.all()[:limit] class Meta: abstract = True