Get posts of users using *ngFor (angular + apollo + graphcool)

148 Views Asked by At

I have this query graphql in Graphcool:

const FeedQuery = gql`
     query FeedPosts($id:ID!){
          User(id:$id){
              id
              follows{
                 id
                 followed{
                     id
                     name
                     lastname
                     posts{
                        id
                        title
                        description
                        city
                        state   
        } }} }}`;

I tried to map using rxjs but I could only get the data from the "followed" level of the query ... How to get a list of "posts" using the apollo + angular * ngFor? ...

1

There are 1 best solutions below

0
On

I got the answer in this Topic …I changed the query to:

const FeedQuery = gql`
query FeedPosts($id: ID!){
 allPosts(filter:{
           user:{
          followedBy_some:{
               follower:{
                   id:$id
         }
         }  
    }
 }) {
id
title
description
title
description
createdAt
user{
    id
    name
    }
   } } `;

using _some can get the related fields