Returning dgraph types from lambda resolvers

I noticed that querying something like

query {
  myCustomLambdaQuery {
    id
    relatedType {
      id
    }
  }
}

it will fail because the lambda returns null for relatedType. This seems like a pretty big limitation, because I don’t see a way to anticipate how someone will use the query (e.g. how deep they go in the graph). Am I missing something here?

Hi @repomaa, what is your myCustomLambdaQuery ? does it return anything for relatedtype field.
I think you should be able to query nested field if the object lamda server returns have that field.

I think, he means that he would need to query all sub-fields up to infinite depth of relatedType inside his lambda-resolver.

relatedType is defined in the schema as a “regular” dgraph type.

But I’m just guessing here, maybe @repomaa can clarify.

1 Like

I think there is already a story for this somewhere. Basically, if you are expecting a lambda to return a type, then returning a set of uids from the lambda should cause dgraph to look up the relevant records

1 Like

yes this is exactly what i meant

A bit related to: Lambda/Custom Resolver Filtering allowed or not?

For now, for such things, we have decided to send the User’s query over to lambda resolver in an info object, so that the lambda resolver can dynamically form the exact DQL/GraphQL that is required to get the correct results and return those results back to Dgraph. See this PR for reference: feat(GraphQL): add selection set of query to the body of lambda request. by minhaj-shakeel · Pull Request #7718 · dgraph-io/dgraph · GitHub

And, as suggested by @gja this is also a feature that is planned, but no ETA yet for this.

2 Likes

Hi @abhimanyusinghgaur
When will this be available in master? I need it right now. Or even better @gja’s proposal.

Hey @maaft,

The changes in the dgraph-lambda project are being worked upon currently. It might all be available by the end of next week in master.

Thanks

2 Likes

Hi @abhimanyusinghgaur

when will this be published to master? I see that this is already merged in dgraph-lambda.