fork of hey-api/openapi-ts because I need some additional things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(pinia-colada): streamline `queryKey` creation

+19 -24
+19 -24
packages/openapi-ts/src/plugins/@pinia/colada/queryOptions.ts
··· 42 42 operation, 43 43 }); 44 44 45 - const hasAnyRequestFields = hasOperationPathOrQueryAny(operation); 46 45 if (!state.hasQueries) { 47 46 state.hasQueries = true; 47 + } 48 48 49 - if (hasAnyRequestFields && !state.hasCreateQueryKeyParamsFunction) { 50 - createQueryKeyType({ plugin }); 51 - createQueryKeyFunction({ plugin }); 52 - state.hasCreateQueryKeyParamsFunction = true; 53 - } 49 + if (!state.hasCreateQueryKeyParamsFunction) { 50 + createQueryKeyType({ plugin }); 51 + createQueryKeyFunction({ plugin }); 52 + state.hasCreateQueryKeyParamsFunction = true; 54 53 } 55 54 56 55 const symbolUseQueryOptions = f.ensureSymbol({ ··· 71 70 name: operation.id, 72 71 }), 73 72 }); 74 - if (hasAnyRequestFields) { 75 - const node = queryKeyStatement({ 76 - operation, 77 - plugin, 78 - symbol: symbolQueryKey, 79 - }); 80 - symbolQueryKey.update({ value: node }); 81 - } 73 + const node = queryKeyStatement({ 74 + operation, 75 + plugin, 76 + symbol: symbolQueryKey, 77 + }); 78 + symbolQueryKey.update({ value: node }); 82 79 83 80 const typeData = useTypeData({ operation, plugin }); 84 81 const { strippedTypeData } = getPublicTypeData({ 85 82 plugin, 86 83 typeData, 87 84 }); 85 + const hasAnyRequestFields = hasOperationPathOrQueryAny(operation); 86 + const needsOptionsScope = hasAnyRequestFields || !!operation.body; 88 87 const awaitSdkExpression = tsc.awaitExpression({ 89 88 expression: tsc.callExpression({ 90 89 functionName: queryFn, 91 90 parameters: [ 92 - hasAnyRequestFields 91 + needsOptionsScope 93 92 ? tsc.objectExpression({ 94 93 multiLine: true, 95 94 obj: [ ··· 130 129 const queryOptionsObj: Array<{ key: string; value: ts.Expression }> = [ 131 130 { 132 131 key: 'key', 133 - value: hasAnyRequestFields 134 - ? tsc.callExpression({ 135 - functionName: symbolQueryKey.placeholder, 136 - parameters: [optionsParamName], 137 - }) 138 - : tsc.arrayLiteralExpression({ 139 - elements: [tsc.ots.string(operation.id)], 140 - }), 132 + value: tsc.callExpression({ 133 + functionName: symbolQueryKey.placeholder, 134 + parameters: needsOptionsScope ? [optionsParamName] : [], 135 + }), 141 136 }, 142 137 { 143 138 key: 'query', ··· 176 171 expression: tsc.callExpression({ 177 172 functionName: 'defineQueryOptions', 178 173 parameters: [ 179 - hasAnyRequestFields 174 + needsOptionsScope 180 175 ? tsc.arrowFunction({ 181 176 parameters: [ 182 177 {