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

fix(package/gqty): useTransactionQuery should work without suspense #2188

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vicary
Copy link
Member

@vicary vicary commented Mar 4, 2025

Fixes #2187

Screen.Recording.2025-03-04.at.16.58.33.mov

@vicary vicary force-pushed the fix(package/gqty)/useTransactionQuery branch from a1939cd to 8ebcff1 Compare March 4, 2025 09:01
@vicary vicary force-pushed the fix(package/gqty)/useTransactionQuery branch from 8ebcff1 to 1da6588 Compare March 4, 2025 09:02
Copy link
Contributor

github-actions bot commented Mar 4, 2025

🚀 Snapshot Release (canary)

The latest changes of this PR are available as canary on npm (based on the declared changesets):

Package Version Info
@gqty/react 3.1.1-canary-20250304090326.1da6588049480a27515b511171d5509edd3b0ec9 npm ↗︎ unpkg ↗︎

@vicary
Copy link
Member Author

vicary commented Mar 4, 2025

@cdomigan Please feel free to test this canary, I'll release the patch once you find it working!

@vicary vicary self-assigned this Mar 4, 2025
@vicary vicary added the bug Something isn't working label Mar 4, 2025
@cdomigan
Copy link

cdomigan commented Mar 7, 2025

Not sure if I'm using it wrong, but I'm getting partial results returned, eg adding the following test to packages/react/test/useTransactionQuery.test.tsx:

  it('should not return partially undefined results', async () => {
    const { useTransactionQuery } = await createReactTestClient();

    const { result } = renderHook(() =>
      useTransactionQuery((query) => {
        const human = query.human();
        return {
          name: human.name
        };
      }, { suspense: false })
    );

    expect(result.current.data).toBeUndefined();
    await waitFor(() => expect(result.current.data).not.toBeUndefined());
    expect(result.current.data?.name).toBeInstanceOf(String);
  });

I'm seeing

packages/react test:   ● useTransactionQuery › should not return partially undefined results
packages/react test:     expect(received).toBeUndefined()
packages/react test:     Received: {"name": undefined}

The docs say that the data returned is only available after a successful fetch., so I had expected data to be undefined until it had successfully resolved?

@vicary
Copy link
Member Author

vicary commented Mar 7, 2025

@cdomigan You may have to wait until isLoading turns true and then false again to mean a successful fetch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

useTransactionQuery never fetches
2 participants