Re-sending a failed query
raysarebest opened this issue · 5 comments
I've integrated the Query
widget into my app, and it works just fine the first time it runs. However, I'd like to have a "try again" button if the query fails that would re-send the query. However, I can't figure out how to refresh/re-send a query. I've written the following code so far, and every time I hit "try again", I can see Built event widget tree
printed to my console, but the query itself isn't re-sent:
@override Widget build(BuildContext context) {
print("Built event widget tree");
const request = '''
{
festapp(id:"931") {
events {
name
startsAt
image
}
}
}
''';
return Query(
options: QueryOptions(
document: request,
fetchPolicy: FetchPolicy.noCache,
errorPolicy: ErrorPolicy.all,
pollInterval: 5
),
builder: (QueryResult result) {
if (result.errors != null) {
return Center(child:
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(result.errors.toString()),
CupertinoButton.filled(
child: Text("Try again"),
onPressed: (){
setState((){});
},
)
],
)
);
}
if (result.loading) {
return Center(
child: CupertinoActivityIndicator(
radius: 20,
animating: true,
),
);
}
List events = result.data["festapp"]["events"];
return ListView.separated(itemBuilder: (context, row) => EventCell(Event.fromAPIData(events[row])),
separatorBuilder: (context, row) {
return Container(
height: 1,
color: Color.fromARGB(20, 0, 0, 0),
margin: EdgeInsets.only(left: 8),
);
},
itemCount: events.length);
}
);
}
@raysarebest I'm happy to tell you a retry function was added several weeks ago. I have some pending issues to fix before pushing an making a final release.
@raysarebest我很高兴告诉你几个星期前添加了重试功能。在推送最终版本之前,我还有一些待解决的问题需要解决。
Well done
Awesome! If you wouldn't mind commenting on this issue when it's available, I'd appreciate it 🙂
@raysarebest sure I will. And sorry for the delay, I recently moved to Norway so it took some time to fully settle in
Ah wow yeah, that's quite a move. I've lived in Stockholm for a few months before, so I know how weird Scandinavia can be if you're not used to it 😅Enjoy getting settling in, and take your time with the fix. Moves are stressful, especially international ones