I have a type in my schema and it looks like this (simplified):
type CompetencyCategory {
_id: Long!
id: String!
label: String!
competencys: [Competency] @relation(name: "IS_IN_GROUP", direction: "IN")
sumOfChildComps: Int
@cypher(
statement: """
MATCH (this)-[:CATEGORY_HAS_COMPETENCIES_OF]->(comp:Competency)-[up:HAS_USER_PROGRESS]-(p1:Progress)
WHERE up.userId = '1'
RETURN sum(p1.currentLevel)
"""
)
}
When I query the data with GraphQL:
{
CompetencyCategory {
id
label
sumOfChildComps
}
}
I get this as expected:
{
"data": {
"CompetencyCategory": [
{
"id": "LT-1932629939382148",
"label": "Group1",
"sumOfChildComps": 22
}
}
Now I want to replace the hardcoded WHERE up.userId = '1'
with a variable such as
WHERE up.userId = $targetUserId
and provide a value for that variable on every query.
So, how do I define an arbitrary string variable (not an named object in the database) in the schema, and where do I pass a parameter on every query to replace the hardcoded "1" in WHERE up.userId = '1'
?
I see that cypher params (for things like authentication) are defined when ApolloServer is created, so that's way too early. This value will change on every query.
I'm using Neo4j 3.5, and neo4j-graphql-js 2.12.1
~Matthew