Curent user's posts: UDF + graphql

Hi,
I’ve a classic case of users posts and comments:

    type User @collection(name: "users") {
      email: String! @unique(index: "unique_user_email")
      posts: [Post] @relation(name: "user_posts")
    }
    type Post @collection(name: "posts") {
      author: User! @relation(name: "user_posts")
      text: String!
      category: Category @relation(name: "post_category")
    }
    type Category @collection(name: "categories") {
      posts: [Post] @relation(name: "post_category")
      title: String!
    }
    type Query {
      my_posts: [Post]! @resolver(name: "my_posts")
    }

The function my_posts is:

    Query(
      Lambda(
        'x',
        Map(
          Paginate(Match(Index("user_posts_by_user"), Get(Identity()))),
          Lambda("ref", Get(Var("ref")))
        )
      )
    )

Then my graphql query

    query {
      my_posts {
        text
        category {
          title
        }
      }
    }

The error message I’m getting is:
Can't convert '{data: [{text: \"Foo\", category: {_id: ref(id = \"277903955769426437\", class = ref(id = \"categories\", class = ref(id = \"classes\")))}}, {text: \"Bar\", category: {_id: ref(id = \"277904181709242887\", class = ref(id = \"categories\", class = ref(id = \"classes\")))}}]}' to Vector

any idea how to get out of this little mess?! thank you :slight_smile:

Can you try updating your function to

    Query(
      Lambda(
        'x',
        Select(["data"], Map(
          Paginate(Match(Index("user_posts_by_user"), Get(Identity()))),
          Lambda("ref", Get(Var("ref")))
        )
       )
      )
    )

Amazing! I was quite close then :smiley: Thank you @Jay-Fauna

A side note, I’ve replaced Get(Identity()) with just Identity() to fix another error