✅ Question about GraphQL queries

May 25, 2020 at 9:05am

✅ Question about GraphQL queries

May 25, 2020 at 9:05am (Edited 5 months ago)
I'm trying to retrieve all of the messages using GraphQL at Postwoman, as the documentation suggests. But when I do the query like this:
{"query": "subscription { MessageReadModel { id body } }" }
{"query": "subscription { CartReadModel(id:\"demo\") { id items } }" }
but removing the id, as I don't need to filter through id but getting all of the Messages available. In this case, it returns an error saying that the ID is mandatory to perform the query
argument id of type ID is required but it was not provided
If I try to set the ID as optional in the ReadModel declaration, it shows an error, as the ReadModel decorator requires it
At this point, how is it possible to subscribe to all of the updates without that id??

May 28, 2020 at 4:02pm
have you tried:
{"query": "subscription { CartReadModels { id items } }" } ?
When retrieving several items, we shall use the right query. You can see them in the GraphQL schema
You can easily grab the schema through postwoman
  • reply
  • like
Yes, that's the first thing I tried. When I do:
{"query": "subscription { MessageReadModel { id body } }" }
The response I get is:
[RECEIVED]: {"errors":[{"message":"Field \"MessageReadModel\" argument \"id\" of type \"ID!\" is required, but it was not provided.","locations":[{"line":1,"column":16}]}]}
I tried getting the schema and it says that ID is mandatory, as the response. So, how can I get all of the MessageReadModels?? I mean, without setting that id
And also, removing the ID from the ReadModel declaration is not a possibility, as the ReadModel decorator needs it
  • reply
  • like

May 29, 2020 at 11:53am
I got to make it work. In my case the query was wrong, as I have to get MessageReadModels, note the 'S' at the end. Apart from that, I needed to set the filter. The final query that worked for me was
{"query": "subscription { MessageReadModels(id: {
operation: notEq
values: []
}" }
Thanks for the support and
  • reply
  • like

August 10, 2020 at 5:08pm
This conversation has been locked