Skip to content

queryFn signature does not model fallibility for 'queryError #2

@cdaringe

Description

@cdaringe

Problem

My queryFn returned promise.t has a result<'a, 'e>, but I 'queryError is completely disassociated.

queryFn: ReactQuery_Types.queryFunctionContext<'queryKey, 'pageParam> => Js.Promise.t<'queryData>

Discussion

As rescript users denote, Js.Promise is more or less worthless for modelling error types, which turns out is pretty critical for JS applications.

I'm currently using aantron/promise which at runtime is the practical mapping between this library's 'queryError and my 'e of result<'a, 'e>. The same could be said for ryyppy's or yawaramin's promise impl's as well.

I'm curious if there's a way to abstract the types here to satisfy the status quo, but also play nicely with result aware promise impls that care about modelling the error case. perhaps a GADT on the return type could be applicable and processed accordingly in the the useQuery impl?

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