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.23k stars 608 forks source link

QueryWidget still makes query request when is not rendered anymore #1442

Open mthinh opened 2 weeks ago

mthinh commented 2 weeks ago

Describe the issue

Widget build(BuildContext context) {
    final loggedInUserId = context.watch<AuthBloc>().state.maybeWhen(
          orElse: () => '',
          authenticated: (user) => user.userId,
        );
    if (loggedInUserId.isEmpty) {
      return const SliverToBoxAdapter(
        child: SizedBox.shrink(),
      );
    }
    return Query$GetUserDiscoverySwipes$Widget(
      options: Options$Query$GetUserDiscoverySwipes(
        variables: Variables$Query$GetUserDiscoverySwipes(
          skip: 0,
          limit: 100,
          state: Enum$UserDiscoverySwipeState.pending,
        ),
      ),

As above, I only render QueryWidget when ever the user is logged in, but somehow when I logged out, the query request is still called, I tried to add breakpoint, the widget is not rendered, but the request is still proceed

Expected behavior The request should not be called when the widget is not rendered anymore

device / execution context