I am trying to create an upsert in a dql lambda in slash dgraph. Here is my schema:
type User {
email: String! @search(by: [hash]) @id
displayName: String! @search
posts: @hasInverse(field: user)
}
type Post {
id: ID!
name: String! @search(by: [fulltext])
description: String! @search(by: [fulltext])
published: Boolean!
user: User
}
I want to add a Post by a certain user. Here is my query, args being my incoming data:
upsert {
query {
q(func: eq(email, "${args.email}")) {
v as uid
}
}
mutation {
set {
_:blank-0 <Post.name> "${args.name}" .
_:blank-0 <Post.description> "${args.description}" .
_:blank-0 <Post.user> uid(v) .
_:blank-0 <Post.published> "${args.published}" .
_:blank-0 <dgraph.type> "Post" .
}
}
}
The mutation works fine, but the User field is empty.
I believe there is something wrong with this line:
_:blank-0 <Post.user> uid(v) .
What I mentally want to do is this:
_:blank-0 <Post.user.email> "${args.email}"
How can this be done?
Thanks,
J