Currently, I am collaborating on a project using Angular and Django. The data is being sent from Django to Angular using GraphQL. In Angular, I have created a custom type called "TopicType" where I successfully captured the data. However, I encountered an issue with the type as I am sending both the name and score of topics and I need the values to be separated. Below is my type.ts file:
export type TopicType = {
subreddit : string;
score : number;
}
export type Query = {
all_Topics : TopicType[];
}
This is how I retrieve the data in api-service.ts :
public getAllTopic = () =>{
this.apollo.query({
query: gql`query getTopics{
allTopics {
subreddit
score
}
}
`
}).subscribe(result => {
this.graphql_topics = result.data as TopicType[];
console.log(this.graphql_topics)
return this.graphql_topics;
})
}
As shown in the result here:
I am trying to access each topic and its corresponding score by using this.graphql_topics[0], but it's not yielding the desired outcome.