Skip to content

Commit

Permalink
fix(query): correctly set global options
Browse files Browse the repository at this point in the history
  • Loading branch information
anymaniax committed Jun 7, 2024
1 parent bb7955a commit 8d3b3ea
Showing 1 changed file with 40 additions and 31 deletions.
71 changes: 40 additions & 31 deletions packages/orval/src/utils/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,13 @@ export const normalizeOptions = async (

const defaultFileExtension = '.ts';

const globalQueryOptions = {
useQuery: outputOptions.override?.query?.useQuery ?? true,
useMutation: outputOptions.override?.query?.useMutation ?? true,
signal: outputOptions.override?.query?.signal ?? true,
shouldExportMutatorHooks:
outputOptions.override?.query?.shouldExportMutatorHooks ?? true,
shouldExportHttpClient:
outputOptions.override?.query?.shouldExportHttpClient ?? true,
shouldExportQueryKey:
outputOptions.override?.query?.shouldExportQueryKey ?? true,
const globalQueryOptions: NormalizedQueryOptions = {
useQuery: true,
useMutation: true,
signal: true,
shouldExportMutatorHooks: true,
shouldExportHttpClient: true,
shouldExportQueryKey: true,
...normalizeQueryOptions(outputOptions.override?.query, workspace),
};

Expand Down Expand Up @@ -231,18 +228,7 @@ export const normalizeOptions = async (
},
},
hono: normalizeHonoOptions(outputOptions.override?.hono, workspace),
query: {
useQuery: outputOptions.override?.query?.useQuery ?? true,
useMutation: outputOptions.override?.query?.useMutation ?? true,
signal: outputOptions.override?.query?.signal ?? true,
shouldExportMutatorHooks:
outputOptions.override?.query?.shouldExportMutatorHooks ?? true,
shouldExportHttpClient:
outputOptions.override?.query?.shouldExportHttpClient ?? true,
shouldExportQueryKey:
outputOptions.override?.query?.shouldExportQueryKey ?? true,
...normalizeQueryOptions(outputOptions.override?.query, workspace),
},
query: globalQueryOptions,
zod: {
strict: {
param: outputOptions.override?.zod?.strict?.param ?? false,
Expand Down Expand Up @@ -640,15 +626,38 @@ const normalizeQueryOptions = (
),
}
: {}),
shouldExportQueryKey:
queryOptions.shouldExportQueryKey ?? globalOptions.shouldExportQueryKey,
shouldExportHttpClient:
queryOptions.shouldExportHttpClient ??
globalOptions.shouldExportHttpClient,
shouldExportMutatorHooks:
queryOptions.shouldExportMutatorHooks ??
globalOptions.shouldExportMutatorHooks,
signal: queryOptions.signal ?? globalOptions.signal,
...(!isUndefined(globalOptions.shouldExportQueryKey)
? {
shouldExportQueryKey: globalOptions.shouldExportQueryKey,
}
: {}),
...(!isUndefined(queryOptions.shouldExportQueryKey)
? { shouldExportQueryKey: queryOptions.shouldExportQueryKey }
: {}),
...(!isUndefined(globalOptions.shouldExportHttpClient)
? {
shouldExportHttpClient: globalOptions.shouldExportHttpClient,
}
: {}),
...(!isUndefined(queryOptions.shouldExportHttpClient)
? { shouldExportHttpClient: queryOptions.shouldExportHttpClient }
: {}),
...(!isUndefined(globalOptions.shouldExportMutatorHooks)
? {
shouldExportMutatorHooks: globalOptions.shouldExportMutatorHooks,
}
: {}),
...(!isUndefined(queryOptions.shouldExportMutatorHooks)
? { shouldExportMutatorHooks: queryOptions.shouldExportMutatorHooks }
: {}),
...(!isUndefined(globalOptions.signal)
? {
signal: globalOptions.signal,
}
: {}),
...(!isUndefined(queryOptions.signal)
? { signal: queryOptions.signal }
: {}),
...(!isUndefined(globalOptions.version)
? {
version: globalOptions.version,
Expand Down

0 comments on commit 8d3b3ea

Please sign in to comment.