Open
Description
-
I'm submitting a ...
[ ] bug report
[x] feature request
[ ] question about the decisions made in the repository
[ ] question about how to use this project -
Summary
We're using the autogenSWRKey
option (which is great!), but we have some situations where we need more fine-grained control over the key.
However, it seems onerous to disable autogenSWRKey
entirely just for a few edge-cases. It would be nice if there was a way to override the generated key on a case-by-case basis.
- Other information (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)
I think something like this would do the trick:
useMyQuery(
variables: MyQueryQueryVariables,
config?: SWRConfigInterface<MyQueryQuery, ClientError>,
keyOverride?: SWRKeyInterface,
) {
return useSWR<MyQueryQuery, ClientError>(
keyOverride ?? genKey<MyQueryQueryVariables>('MyQuery', variables),
() => sdk.myQuery(variables),
config,
);
}
I'd be happy to open a PR for this.
I think this would potentially resolve #124 as well.
Metadata
Metadata
Assignees
Labels
No labels