Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about GraphQL queries #340

Closed
NickSeagull opened this issue Aug 10, 2020 · 3 comments
Closed

Question about GraphQL queries #340

NickSeagull opened this issue Aug 10, 2020 · 3 comments
Labels
question Further information is requested

Comments

@NickSeagull
Copy link
Member

Submitted by @carlosper88 in Spectrum

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 } }" }

Same one as the example in the documentation

{"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??

@NickSeagull NickSeagull added the question Further information is requested label Aug 10, 2020
@NickSeagull
Copy link
Member Author

Response by @tainguyenbui

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 https://postwoman.io/graphql

@NickSeagull
Copy link
Member Author

Response by @carlosper88

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

@NickSeagull
Copy link
Member Author

Response by @carlosper88

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: []
}) 
{
    id 
    body 
} 
}" }

Thanks for the support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant