Fields marked with @hasInverse do not populate in @lambda parent object

What version of Dgraph are you using?


Have you tried reproducing the issue with the latest release?


What is the hardware spec (RAM, OS)?

Dgraph Cloud

Steps to reproduce the issue

Add a user and add GameScores related to that user


type User  {
  id: ID!
  username: String! @id @search(by: [fulltext])
  scores: [GameScore]! @hasInverse(field: "user")
  high_score: GameScore @lambda

type GameScore {
  user: User!
  record_date: DateTime!
  score: Int!


const generateHighScore = (parent)  => {

  "User.high_score": generateHighScore

Expected behaviour and actual result.

Expected log of parent :

{ id: "0xExample", userName: "exampleName", scores: [ ] }

Actual log of parent :

{ id: "0xExample", userName: "exampleName" }

The goal was to make a simple Lambda that produced the high score from the score nodes connected to a given user. Every user is initialized with an empty array as the “scores” field. This field does not show up in the parent object when calling the lambda.

Hey @kdilla301,

IIRC, only ‘scalars’ are sent to lambda handlers. So this limits what can be done, but I think I have a solution for you.

Note that there are two types of lambdas: query resolvers and mutation handlers. You’re sort of mixing the two here. Based on what you posted, I believe the best solution is for the high_score edge to be a query resolver, not a mutation lambda.

Here’s a query resolver that should do the trick…

lambda JS:

async function calculateHighScore({parent, graphql}) {
    const results = await graphql(`
    query {
        getUser(id: "${}") {
          scores(order: {desc: score}, first: 1) {
    return {
        user: {id:},

    "User.high_score": calculateHighScore

Thank you. This is what I was looking for