zino-hofmann / graphql-flutter

A GraphQL client for Flutter, bringing all the features from a modern GraphQL client to one easy to use package.
https://zino-hofmann.github.io/graphql-flutter
MIT License
3.25k stars 620 forks source link

Convert Query results into List #1139

Closed Maria-Donosova closed 2 years ago

Maria-Donosova commented 2 years ago

Hello,

I am not sure if this is the bug or I should request a feature. I use graphql flutter to retrieve the data (appointments) from my mongodb, so I could display it within the Syncfusion calendar. However I get the error message saying that 'The type 'Query is not a subtype of type 'List' in type cast'.

The code: List appointments = Query( options: QueryOptions(document: gql(_getEvents)), builder: (result, {fetchMore, refetch}) { if (result.isLoading) { return const CircularProgressIndicator(); } else { result.data!["events"]; } throw const Text('Something happened'); }) as List; return _DataSource(appointments); }

The expected behavior: have the query converted to list and get the events displayed.

Device / execution context: iOS simulator

What backend are you trying to use? MongoDB, mongoose, node.js, express

Please advise if there is anything that can be done.

Thank you, Maria

budde377 commented 2 years ago

Thanks for reaching out! The problem is that you're assigning a query widget to a list. This fails because the query instance is not a list.

I think you need to take a look at the readme of the package to get an fundamental understanding of how this library works. The Query is a widget and should be handled as such.