-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
area/querylang/varsIssues related to queries with GraphQL variablesIssues related to queries with GraphQL variablesarea/upsertIssues related to upsert operations.Issues related to upsert operations.kind/bugSomething is broken.Something is broken.
Description
Working Upsert
const query = `
query {
user as q(func: eq(user.id, "${request.userId}"))
}
`;
const mu = new dgraph.Mutation();
mu.setDelNquads(`uid(user) * * .`);
const req = new dgraph.Request();
req.setQuery(query);
req.setMutationsList([mu]);
req.setCommitNow(true);
const res = await dgraphClient.newTxn().doRequest(req);
When directly inserting the value of request.userId into the query string via string interpolation, the node returned by the query is successfully deleted.
Failing upsert
const query = `
query q($userId: string) {
user as q(func: eq(user.id, $userId))
}
`;
const mu = new dgraph.Mutation();
mu.setDelNquads(`uid(user) * * .`);
const req = new dgraph.Request();
const vars = req.getVarsMap();
vars.set("$userId", `${request.userId}`);
req.setQuery(query);
req.setMutationsList([mu]);
req.setCommitNow(true);
const res = await dgraphClient.newTxn().doRequest(req);
When trying to use query variables and setting the corresponding entry in the variables map for $userId with `${request.userId}`, the node that should be returned by the query is not successfully deleted.
Is this an unsupported feature for upserts or is something wrong with the code?
Metadata
Metadata
Assignees
Labels
area/querylang/varsIssues related to queries with GraphQL variablesIssues related to queries with GraphQL variablesarea/upsertIssues related to upsert operations.Issues related to upsert operations.kind/bugSomething is broken.Something is broken.