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

Re-sending a failed query #13

Open
raysarebest opened this issue Apr 9, 2019 · 5 comments
Open

Re-sending a failed query #13

raysarebest opened this issue Apr 9, 2019 · 5 comments

Comments

@raysarebest
Copy link

raysarebest commented Apr 9, 2019

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);
        }
    );
  }
@juicycleff
Copy link
Contributor

@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.

@chenxianqi
Copy link

@raysarebest我很高兴告诉你几个星期前添加了重试功能。在推送最终版本之前,我还有一些待解决的问题需要解决。

Well done

@raysarebest
Copy link
Author

Awesome! If you wouldn't mind commenting on this issue when it's available, I'd appreciate it 🙂

@juicycleff
Copy link
Contributor

@raysarebest sure I will. And sorry for the delay, I recently moved to Norway so it took some time to fully settle in

@raysarebest
Copy link
Author

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

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

No branches or pull requests

3 participants