You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I'd like to use custom serialization for $error store in query and mutation.
My use case:
I have a project that uses nextjs and farfetched, sometimes a NetworkError can happen on the server side, this type of error has a non-serializable property "cause". In this situation I can't to serialize queries running on the server. Now the only one solution is to set serialize property to 'ignore', but it will disable serialization for all stores. That's not what i want.
My suggestion:
I think that it would be nice to separate serialization for $error and $data. As i understood, now serialization property works like this:
If serialization equals to 'ignore', it will disable all serialization
If serialization equals to {write: ..., read...}, this rules will be used only for $data store, and will have no effect for all other stores
And I suggest changing this behavior to this: type Serialize<Data | Initial> = Serialize<Data | Initial> | {error?: Serialize<Data | Initial>, data?: Serialize<Data | Initial>} | undefined;
If serialization equals to 'ignore' or {write: ..., read...}, it will works like before
If serialization equals to {error: ..., data: ... }, it will apply different serialization rules for $error and $data
Hope my suggestion helps!
The text was updated successfully, but these errors were encountered:
Hi! I'd like to use custom serialization for
$error
store in query and mutation.My use case:
I have a project that uses nextjs and farfetched, sometimes a NetworkError can happen on the server side, this type of error has a non-serializable property "cause". In this situation I can't to serialize queries running on the server. Now the only one solution is to set
serialize
property to'ignore'
, but it will disable serialization for all stores. That's not what i want.My suggestion:
I think that it would be nice to separate serialization for
$error
and$data
. As i understood, nowserialization
property works like this:serialization
equals to'ignore'
, it will disable all serializationserialization
equals to{write: ..., read...}
, this rules will be used only for $data store, and will have no effect for all other storesAnd I suggest changing this behavior to this:
type Serialize<Data | Initial> = Serialize<Data | Initial> | {error?: Serialize<Data | Initial>, data?: Serialize<Data | Initial>} | undefined;
serialization
equals to'ignore'
or{write: ..., read...}
, it will works like beforeserialization
equals to{error: ..., data: ... }
, it will apply different serialization rules for$error
and$data
Hope my suggestion helps!
The text was updated successfully, but these errors were encountered: