Skip to content
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

feat(swr): remove output.orverride.swr.options property #1246

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions docs/src/pages/reference/configuration/output.md
Original file line number Diff line number Diff line change
Expand Up @@ -800,9 +800,6 @@ module.exports = {
override: {
swr: {
useInfinite: true,
options: {
dedupingInterval: 10000,
},
},
},
},
Expand Down
5 changes: 1 addition & 4 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,7 @@ export type NormalizedOperationOptions = {
contentType?: OverrideOutputContentType;
query?: NormalizedQueryOptions;
angular?: Required<AngularOptions>;
swr?: {
options?: any;
};
swr?: SwrOptions;
operationName?: (
operation: OperationObject,
route: string,
Expand Down Expand Up @@ -360,7 +358,6 @@ export type AngularOptions = {
};

export type SwrOptions = {
options?: any;
useInfinite?: boolean;
swrOptions?: any;
swrMutationOptions?: any;
Expand Down
6 changes: 2 additions & 4 deletions packages/swr/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,6 @@ ${doc}export const ${camel(
}\n`
: '';

const defaultSwrOptions = { ...swrOptions.swrOptions, ...swrOptions.options };

const useSwrImplementation = `
export type ${pascal(
operationName,
Expand Down Expand Up @@ -420,9 +418,9 @@ ${doc}export const ${camel(`use-${operationName}`)} = <TError = ${errorType}>(
});

const ${queryResultVarName} = useSwr<Awaited<ReturnType<typeof swrFn>>, TError>(swrKey, swrFn, ${
defaultSwrOptions
swrOptions.swrOptions
? `{
${stringify(defaultSwrOptions)?.slice(1, -1)}
${stringify(swrOptions.swrOptions)?.slice(1, -1)}
...swrOptions
}`
: 'swrOptions'
Expand Down