Type in QueryWithVars

Given I have a node:

<_:1> <type:emailAccount> "" .
<_:1> <name> "test@example.com" .

I want to be able to retrieve the uid given the name and has(<type:emailAccount>).

I am trying to build the query using QueryWithVars and the golang api.

The query works with a hardcoded $type variable.

    variables := map[string]string{
		"$name": Name,
		// "$type": Type,

	q := `
	query uid($name: string)
		uid(func:eq(name, $name)) @filter(has(<type:emailAccount>)) {
	resp, err := txn.QueryWithVars(ctx, q, variables)
	if err != nil {
		return "", err

If i try to use $type as variable, returns the error: rpc error: code = Unknown desc = Got empty attr for function: [has].

What should be the query in order to work using $type to call has($type)?


GraphQL variables are not supported in predicate names right now. Feel free to file an issue and we can support it.

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