Lambda/Custom Resolver Filtering allowed or not?


Report a Dgraph Bug

What version of Dgraph are you using?

Dgraph Version
$ dgraph version
 
20.11.0-rc1-441-gf4c857b8

Have you tried reproducing the issue with the latest release?

What is the hardware spec (RAM, OS)?

16GB Docker Win10

Steps to reproduce the issue (command/config used to run Dgraph).

type Author {
    id: ID!
    name: String! @search(by: [hash, trigram])
    reputation: String
    book: [Book]
}

type Book {
    id: ID!
    name: String! @search(by: [hash, trigram])
}

type Query {
    authorsByName(name: String!): [Author] @lambda
}
query {
  authorsByName(name: "SomeName") {
    id
    name
    reputation
    book(filter: {
      name: {
        eq: "Harry Potter 3"
      }
    })
    {
      id
      name
    }
  }
}

Given an resolver that returns some data.

Expected behaviour and actual result.

{
  "data": {
    "authorsByName": [
      {
        "id": "0x7545",
        "name": "Andreas W�rgbauer",
        "reputation": "1.0",
        "book": [
          {
            "id": "0x753d",
            "name": "Harry Potter 3"
          },
          {
            "id": "0x753f",
            "name": "Harry Potter 1"
          }
        ]
      }
    ]
  },
  "extensions": {
    "tracing": {
      "version": 1,
      "startTime": "2021-03-12T06:19:29.8851028Z",
      "endTime": "2021-03-12T06:19:32.1993587Z",
      "duration": 2314255900
    }
  }
}

What I think should be done is this!

{
  "data": {
    "authorsByName": [
      {
        "id": "0x7545",
        "name": "Andreas W�rgbauer",
        "reputation": "1.0",
        "book": [
          {
            "id": "0x753d",
            "name": "Harry Potter 3"
          }
        ]
      }
    ]
  },
  "extensions": {
    "tracing": {
      "version": 1,
      "startTime": "2021-03-12T06:19:29.8851028Z",
      "endTime": "2021-03-12T06:19:32.1993587Z",
      "duration": 2314255900
    }
  }
}

Is this a feature you plan or a bug?
I noticed the same on the Custom Resolvers but there a cant set any filters at all!

1 Like

Hi @Florian, Currently filtering on custom or lambda queries are not supported. You have to write this inside the queries in lambda script only. We will discuss this internally and plan to add this feature in future. Thanks.

2 Likes

How can you parse the filter to the lambda to write the queries in the lambda script? Is this possible?

Hi @JatinDevDG , what’s the status of this feature or will this be a feature soon?

Greetings =)

I also need this feature, is it in the roadmap?