Skip to content

Ability to disable query error when response does not match responseSchema #5222

@stambekovbera

Description

@stambekovbera

I am using the responseSchema option to validate server responses. When the received data does not match the schema, useQuery returns an error state (isError: true).

I would like to achieve the following behavior:
If the HTTP request succeeds, useQuery should return the raw response data even when it does not match the schema, while schema validation errors can be handled via onSchemaFailure (for example, for logging purposes).

Is there a way to disable this behavior using a configuration flag in createApi or some other global option? I could not find any information about this in the documentation.

I am aware of the transformResponse approach with manual schema.parse / schema.safeParse, but this requires duplicating the same logic in every endpoint, which I would like to avoid.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions