Skip to content

feat: Add support for mutation-specific options#1137

Merged
mrlubos merged 5 commits into
hey-api:mainfrom
BierDav:main
Oct 10, 2024
Merged

feat: Add support for mutation-specific options#1137
mrlubos merged 5 commits into
hey-api:mainfrom
BierDav:main

Conversation

@BierDav

@BierDav BierDav commented Oct 10, 2024

Copy link
Copy Markdown
Contributor

Use case:

You have one class let's call it ApiMutatations that calls all the createMutations once and stores it in a variable for later use. But you don't want to mess around with the default api, because when you use solid-js for example it's a lot more clean to use Contexts instead of global variables which might not have been configured (interceptors attached) already.

In our ApiMutations class we want to ensure that the correct Client is preconfigured, unfortunately until now, this was impossible. This small change covers this use case.

@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@changeset-bot

changeset-bot Bot commented Oct 10, 2024

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 80632ad

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@hey-api/openapi-ts Patch

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

@vercel

vercel Bot commented Oct 10, 2024

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hey-api-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 10, 2024 1:28pm

@vercel

vercel Bot commented Oct 10, 2024

Copy link
Copy Markdown

Deployment failed with the following error:

The provided GitHub repository does not contain the requested branch or commit reference. Please ensure the repository is not empty.

@BierDav BierDav marked this pull request as ready for review October 10, 2024 11:51
@BierDav BierDav changed the title Add support for mutation-specific options feat: Add support for mutation-specific options Oct 10, 2024

@mrlubos mrlubos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @BierDav, nice pull request! You will want to update snapshots with pnpm openapi-ts test:update so everything passes. Other than that, only a few nits

parameters: [
{
name: 'options',
name: 'localOptions',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you rename this to mutationOptions?

Suggested change
name: 'localOptions',
name: 'mutationOptions',

spread: 'options',
},
{
spread: 'localOptions',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
spread: 'localOptions',
spread: 'mutationOptions',

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah also though about that, I could and it would probably work, but I creates a naming collision with the local variable that is used for typing. A nice solution would be to add support for the as keyword of typescript, but I don't want to mess around with this selfmade solution

Comment on lines +631 to +632
}) =>
compiler.arrayLiteralExpression({

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this change was done while you were playing around with the code, mind reverting it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IntellIiJ complained, because of the redundant variable, I though I will just fix it. But of course I can revert it.

Comment thread .changeset/real-kangaroos-enjoy.md Outdated
@@ -0,0 +1,5 @@
---
'@hey-api/openapi-ts': minor

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change the release type to patch? Just a preference for how I am currently versioning the package as this is a relatively tiny change

Change changeset level to patch

@mrlubos mrlubos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@codecov

codecov Bot commented Oct 10, 2024

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 8.33333% with 11 lines in your changes missing coverage. Please review.

Project coverage is 80.53%. Comparing base (39d83e2) to head (80632ad).
Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
...napi-ts/src/plugins/@tanstack/query-core/plugin.ts 8.33% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1137      +/-   ##
==========================================
- Coverage   80.60%   80.53%   -0.07%     
==========================================
  Files         107      107              
  Lines       11732    11742      +10     
  Branches     1238     1238              
==========================================
  Hits         9456     9456              
- Misses       2273     2283      +10     
  Partials        3        3              
Flag Coverage Δ
unittests 80.53% <8.33%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pkg-pr-new

pkg-pr-new Bot commented Oct 10, 2024

Copy link
Copy Markdown

Open in Stackblitz

pnpm add https://pkg.pr.new/@hey-api/client-axios@1137
pnpm add https://pkg.pr.new/@hey-api/client-fetch@1137
pnpm add https://pkg.pr.new/@hey-api/openapi-ts@1137

commit: 80632ad

@mrlubos mrlubos merged commit 61d1e15 into hey-api:main Oct 10, 2024
@github-actions github-actions Bot mentioned this pull request Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants