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

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

Open
mthinh opened this issue Jun 28, 2024 · 0 comments
Open

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

mthinh opened this issue Jun 28, 2024 · 0 comments

Comments

@mthinh
Copy link

mthinh commented Jun 28, 2024

Describe the issue

  • QueryWidget still makes query request when is not rendered anymore
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

  • iOS 17.0 Simulator
  • graphql_flutter: ^5.1.2
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

1 participant