graphql-flutter icon indicating copy to clipboard operation
graphql-flutter copied to clipboard

QueryWidget still makes query request when is not rendered anymore

Open mthinh opened this issue 7 months ago • 0 comments

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

mthinh avatar Jun 28 '24 03:06 mthinh