GraphQL queries on Talk


#1

Does anyone have experience with writing GraphQL queries using the Talk’s GraphQL API?
I am trying to write a CommentsQuery, to get all comments that satisfy a given condition. However, since it is not a “RootQuery”, I am unable to figure out the right syntax for it.

Let me take an example scenario: I want to get 10 comments from the “comments” rootQuery
Here are the things I tried (I am trying to send a request via Python’s requests module, if that is relevant):
“query GetComments($limit: Int!){comments(limit:$limit)}”
This gives me an error:
{‘errors’: [{‘message’: ‘Field “comments” of type “CommentConnection” must have a selection of subfields. Did you mean “comments { … }”?’, ‘locations’: [{‘line’: 1, ‘column’: 33}]}, {‘message’: ‘Unknown argument “limit” on field “comments” of type “RootQuery”.’, ‘locations’: [{‘line’: 1, ‘column’: 42}]}, {‘message’: ‘Field “comments” argument “query” of type “CommentsQuery!” is required but not provided.’, ‘locations’: [{‘line’: 1, ‘column’: 33}]}]}

So, I tried this:
query GetComments($limit: Int!){comments($query: CommentsQuery!) {limit: 10} {nodes {status}}}
This gives me a different error:
{‘errors’: [{‘message’: ‘Syntax Error GraphQL request (1:42) Expected Name, found $\n\n1: query GetComments($limit: Int!){comments($query: CommentsQuery!) {limit: 10} {nodes {status}}}\n ^\n’, ‘locations’: [{‘line’: 1, ‘column’: 42}]}]}

The API page only shows a relatively simple example and does not address how I specify something like a “CommentsQuery”, instead of just giving a list of key-value pairs like I would for asset/comment queries.

Can someone suggest me how to go about this?


#2

Hi Sowmya,

The best place to ask questions like this is to open a GitHub Issue: https://github.com/coralproject/talk/issues

Thanks for getting involved with Talk!

Andrew


#3

Thanks, Andrew.
I actually fixed this issue, but I am not seeing a delete post link anywhere. So, I am keeping this here.
However, I ran into another issue, which I posted on github. Thanks.