How to implement User Defined Functions using find API

In the previous post, we have seen implementing User defined functions using upsert API.

Let’s check how to use the find API to read data using the User Defined Function.

Example

We have added data in the StudentInformation type in the previous post.
Here is a findStudent function to read that data. It uses the find API to retrieve the data.

type Query {
findStudent(type: String!,  arcql: String!,  first: Int,  after: String,  last: Int,  before: String,  includeTrashed: Boolean,  page: Int):Json @tan(type:Groovy,  inline:  """return find(type, arcql, first, after, last, before, includeTrashed, page)""")
}

***Use all the find function parameters as UDF parameters.

Let’s execute the function.

{
  findStudent(type:"StudentInformation", arcql:"hypi.id = '01FQNKWHFY409AG458YCQ36RV9'")
}
#result
{
  "data": {
    "findStudent": {
      "edges": [
        {
          "cursor": "01FQNKWHFY409AG458YCQ36RV9",
          "node": {
            "__typename": "StudentInformation",
            "hypi": {
              "__typename": "Hypi",
              "id": "01FQNKWHFY409AG458YCQ36RV9",
              "impl": null,
              "created": "2021-12-24T07:01:06Z",
              "updated": "2021-12-24T07:01:06Z",
              "trashed": null,
              "createdBy": "01FQDY5XDRQPERKPCWAWYDFV7W",
              "instanceId": "01FQDYDP8681299EXZBWJXRX2Y",
              "tags": null
            },
            "name": "XYZ",
            "dob": "2011-05-07T00:00:00Z",
            "address": {
              "__typename": "Address",
              "hypi": {
                "__typename": "Hypi",
                "id": "01FQNKWHFZ9PH0VB0TAP5FJQQP",
                "impl": null,
                "created": "2021-12-24T07:01:06Z",
                "updated": "2021-12-24T07:01:06Z",
                "trashed": null,
                "createdBy": "01FQDY5XDRQPERKPCWAWYDFV7W",
                "instanceId": "01FQDYDP8681299EXZBWJXRX2Y",
                "tags": null
              },
              "door": "23",
              "street": "3A Old Street",
              "town": null,
              "county": null,
              "city": "New Delhi",
              "country": null,
              "postCode": null,
              "from": null,
              "to": null
            },
            "standard": "VII",
            "division": "A",
            "contact": 897675786
          }
        }
      ],
      "pageInfo": {
        "hasPreviousPage": false,
        "hasNextPage": false,
        "startCursor": "FIRST",
        "endCursor": "LAST",
        "pageLimit": 1,
        "previousOffsets": [],
        "nextOffsets": []
      }
    }
  }
}