Skip to content

Commit

Permalink
filter_vertex_by_label renamed to get_vertices
Browse files Browse the repository at this point in the history
  • Loading branch information
Ravi Raja Merugu committed Nov 27, 2022
1 parent 02ed18e commit 9c089e3
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions invana_engine/graph/query_resolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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())

Expand All @@ -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()
Expand Down

0 comments on commit 9c089e3

Please # to comment.