How to find a connecting node that fulfils a certain condition if have uid of source node

I am doing a query which gives me uid of userNode

“user as var(func: eq(name, “+userName+”))\n”

Now this user node has various category node

so what should be my query to get to a specific category node each of which holds a userId and cname

i am trying this query

“category as var(func:eq(cname, “+categoryName+”))”+
“{ “userId @filter(eq(userId,”+userName+”)) }"

Schema is

String schema = “type user {”
" name: string "
" category: [category]"
}
“type category {”
" cname: string"
" userId: string" }"

can someone please help me on this