-
-
Notifications
You must be signed in to change notification settings - Fork 190
feat(tanstack-query): add name and case options #2218
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
Conversation
|
🦋 Changeset detectedLatest commit: e5ff024 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
commit: |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2218 +/- ##
==========================================
- Coverage 25.15% 24.94% -0.21%
==========================================
Files 295 294 -1
Lines 27677 27903 +226
Branches 1272 1272
==========================================
- Hits 6962 6961 -1
- Misses 20706 20933 +227
Partials 9 9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
After this change the name for query/mutation options is not inherited anymore from the result of |
@KiwiKilian can you give an example? I'm inclined to say yes that was the intent, but want to see what has changed on your end |
To generate the same names for import { defineConfig as openapiTsDefineConfig } from '@hey-api/openapi-ts';
export const defineConfig = ({ input, name }: { input: string; name: string }) =>
openapiTsDefineConfig({
input: input,
output: {
clean: true,
path: `src/modules/api/${name}`,
lint: 'eslint',
format: 'prettier',
},
plugins: [
{
name: '@hey-api/typescript',
enums: 'javascript',
},
{
name: '@hey-api/sdk',
methodNameBuilder: (operation) => {
const id = operation.id;
if (!id) {
throw new Error('Missing operation.id');
}
return `${name}Api${id.charAt(0).toUpperCase() + id.slice(1)}`;
},
},
{
name: '@tanstack/react-query',
+ queryOptions: {
+ name: (id) => {
+ return `${name}Api${id.charAt(0).toUpperCase() + id.slice(1)}Options`;
+ },
+ },
+ mutationOptions: {
+ name: (id) => {
+ return `${name}Api${id.charAt(0).toUpperCase() + id.slice(1)}Mutation`;
+ },
+ },
},
],
}); Maybe it would be nice to pass in both the original id an the result of |
Yep, duplication definitely feels like the right abstraction here. You can move that duplicate code into a function if you want to clean up your config a bit. The goal is to more cleanly separate plugins, it's simpler when you don't have to reason through what the SDK plugin does. That being said, I'll likely expose the Plugin API in these methods at some point. You could then grab the |
Absolutely valid, just wanted to make sure, you are aware of the implications. Thank you once again for you work! |
Thanks for the support as always! |
Closes #2195