diff --git a/invana_engine/graph/query_resolvers.py b/invana_engine/graph/query_resolvers.py index a9d0d93..b3bdc66 100644 --- a/invana_engine/graph/query_resolvers.py +++ b/invana_engine/graph/query_resolvers.py @@ -18,7 +18,7 @@ # class RawQuerySchema(graphene.ObjectType): -# filter_vertex_by_label = graphene.Field(graphene.List(GrapheneVertexType), +# get_vertices = graphene.Field(graphene.List(GrapheneVertexType), # label=String(), # # query=JSONString(), @@ -34,8 +34,9 @@ class GremlinGenericQuerySchema: execute_query = graphene.Field(QueryResponseData, timeout=graphene.Int(default_value=DEFAULT_QUERY_TIMEOUT), gremlin=graphene.String()) - filter_vertex_by_label = graphene.Field(graphene.List(NodeType), label=graphene.String(), - limit=graphene.Int(default_value=DEFAULT_PAGINATION_SIZE), skip=graphene.Int()) + + get_vertices = graphene.Field(graphene.List(NodeType), filters=graphene.JSONString(), + limit=graphene.Int(default_value=DEFAULT_PAGINATION_SIZE), skip=graphene.Int()) get_or_create_vertex = graphene.Field(getOrCreateNodeType, label=graphene.String(), properties=graphene.JSONString()) @@ -45,11 +46,9 @@ def resolve_execute_query(self, info: graphene.ResolveInfo, gremlin: str, timeou response = info.context['request'].app.state.graph.execute_query(gremlin, timeout=timeout) return {"data": [d.to_json() if hasattr(d, "to_json") else d for d in response.data] if response.data else []} - def resolve_filter_vertex_by_label(self, info: graphene.ResolveInfo, label: str = None, - limit: int = DEFAULT_PAGINATION_SIZE, skip: int = 0): - filters = {} - if label: - filters['has__label'] = label + def resolve_get_vertices(self, info: graphene.ResolveInfo, filters: dict = None, + limit: int = DEFAULT_PAGINATION_SIZE, skip: int = 0): + filters = {} if filters is None else filters data = info.context['request'].app.state.graph.vertex.search( limit=limit, skip=skip, **filters ).order_by('id').range(skip, limit).to_list()