objection-graphql icon indicating copy to clipboard operation
objection-graphql copied to clipboard

How to extend query with select

Open gu-fan opened this issue 7 years ago • 0 comments

I tried

`postss {
      content
      liked_by_me
}`

onQuery(builder){
        // NOT WORK
        builder
        .select(['posts.*',
            Post.relatedQuery('liked_users').count().as('liked_count'),
            Post.relatedQuery('liked_users').select(raw('true')).where('uid', 1).as('liked_by_me')
        ])
}

but got undefined

remove the liked_by_me field works fine

liked_by_me also works fine in normal query

furthermore, I want to extend the liked_by_me with redis, so how to do that?
requery the redis after getting the actual data from db? then how to bind it to graphql?

any advice?

many thanks

gu-fan avatar Jul 07 '18 20:07 gu-fan