@lambda hook function not called unless ID field is queried

When using @lambda directive on a field, the lambda function is not called unless the ID field is queried as well. Is this the expected behaviour? I’m running the latest lambda-server and dgraph/standalone:v20.11.2 locally.

@abhimanyusinghgaur you know?

Actually, after additional observations, I see the parent object passed to the lambda function only contains the fields that were queried in graphql. However the docs here says:

The parent receives all immediate fields of that object, whether or not they were actually queried.

1 Like

I wonder if this was changed somewhere along the way? @pbassham what is your take on this? You hqve been doing a lot with lambdas today.

I did notice an enum field not coming through. I didn’t look into it much though bc it wasn’t vital to what I was doing.

No, that is not the expected behaviour.

The lambda function should get all the scalar fields from the parent object that are stored in dgraph, whether or not they were actually queried.

I think there is something wrong with your setup. We have a test for lambdas which works fine everytime: dgraph/lambda.go at master · dgraph-io/dgraph · GitHub
You can see there that the GraphQL query doesn’t query for dob but the lambda field is still getting the correct dob for the user and replying with that in the bio field.

Could you reproduce the same on Slash/Dgraph Cloud?