How to use a variable with a language tag in a function?

{
    var(func:eq(rText@zh, "系统")){
        id as rID
    }
    result(func:has(val(id)@zh)) {
        val(id)@zh
    }
}

The query above does not work, as the predicate of val(id) is tagged with Chinese.
Can someone help to solve the problem?

You can set id as the language-tagged rID and then simply use val() to get the value.

id as rID@zh
val(id)
1 Like

You may have misunderstood me, or I don’t have a clear description.

The predicate named rID in the var closure has no language tag, and the relation it represents in my RDF file is as below. So the actual value of variable id is rid_000000, which is the name of another predicate tagged with Chinense.

_:r_000000 <rID> "rid_000000" .

I changed the original query by replace the val(id)@zh with rid_000000@zh, and then I got the right response.

{
    result(func:has(rid_000000@zh)) {
        rid_000000@zh
    }
}

I’m confused about the situation and sincerely hope to get your help.

I don’t think you can treat value variables as predicate names in GraphQL±.

One way you can do what you want from the client-side libraries is to use the GraphQL variables for string substitution within the query.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.