Skip to content

Fix TanStack Query compatibility by adding support for returning null instead of undefined #1468

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Shinevision
Copy link

@Shinevision Shinevision commented Apr 8, 2023

Issue

This pull request aims to address an issue that arises when an endpoint returns a 204 No Content status. Currently, the TanStack query generates an error stating that the Query data cannot be undefined, as demonstrated in the following screenshot:
afbeelding

Solution

To resolve this issue, the proposed solution involves allowing the return of null values instead of undefined by introducing an optional parameter. This change will enable the library to handle 204 No Content responses more gracefully and prevent errors in such scenarios.

Changes

This pull request includes the following changes to the codebase:

  • Added --useNullForNoContent flag in the README, documentation, and command-line options

  • Added useNullForNoContent to the Options type, the generate function, and related utility functions

  • Updated test cases to include the --useNullForNoContent flag

  • Modified the getResponseBody template for one of the core clients (applies to all) to conditionally return null or undefined based on the useNullForNoContent flag

These changes allow the library to support "204 No Content" responses by returning null instead of undefined when the --useNullForNoContent flag is set.

Notes/things to review

  • The useNullForNoContent option / variable name.

@Shinevision Shinevision changed the title Fix TanStack Query compatability by adding support for returning null instead of undefined Fix TanStack Query compatibility by adding support for returning null instead of undefined Apr 8, 2023
Support tests.
@ferdikoomen ferdikoomen self-assigned this Apr 11, 2023
@mrlubos
Copy link
Collaborator

mrlubos commented Jul 23, 2023

Hi @Shinevision, wondering if you've raised an issue with https://github.com/TanStack/query about this, too?

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

Successfully merging this pull request may close these issues.

3 participants