feat: add search parameter to nodes query
All checks were successful
Build Docker Image / build (push) Successful in 1m43s
All checks were successful
Build Docker Image / build (push) Successful in 1m43s
This commit is contained in:
@@ -96,6 +96,7 @@ class Query(graphene.ObjectType):
|
||||
limit=graphene.Int(),
|
||||
offset=graphene.Int(),
|
||||
transport_type=graphene.String(),
|
||||
search=graphene.String(description="Search by node name (case-insensitive)"),
|
||||
)
|
||||
nodes_count = graphene.Int(
|
||||
transport_type=graphene.String(),
|
||||
@@ -263,7 +264,7 @@ class Query(graphene.ObjectType):
|
||||
edges=[EdgeType(**e) for e in edges],
|
||||
)
|
||||
|
||||
def resolve_nodes(self, info, limit=None, offset=None, transport_type=None):
|
||||
def resolve_nodes(self, info, limit=None, offset=None, transport_type=None, search=None):
|
||||
"""Get all logistics nodes (without edges for list view)."""
|
||||
db = get_db()
|
||||
|
||||
@@ -273,6 +274,7 @@ class Query(graphene.ObjectType):
|
||||
FILTER node.node_type == 'logistics' OR node.node_type == null
|
||||
LET types = node.transport_types != null ? node.transport_types : []
|
||||
FILTER @transport_type == null OR @transport_type IN types
|
||||
FILTER @search == null OR CONTAINS(LOWER(node.name), LOWER(@search)) OR CONTAINS(LOWER(node.country), LOWER(@search))
|
||||
SORT node.name ASC
|
||||
LIMIT @offset, @limit
|
||||
RETURN node
|
||||
@@ -281,6 +283,7 @@ class Query(graphene.ObjectType):
|
||||
aql,
|
||||
bind_vars={
|
||||
'transport_type': transport_type,
|
||||
'search': search,
|
||||
'offset': 0 if offset is None else offset,
|
||||
'limit': 1000000 if limit is None else limit,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user