-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
Adds option to disable client auto creation in SDK #1526
base: main
Are you sure you want to change the base?
Conversation
Run & review this pull request in StackBlitz Codeflow. |
🦋 Changeset detectedLatest commit: a0308ab 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 ↗︎
|
73cce83
to
a0308ab
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1526 +/- ##
==========================================
- Coverage 63.35% 63.18% -0.18%
==========================================
Files 150 150
Lines 22748 22860 +112
Branches 1864 1869 +5
==========================================
+ Hits 14412 14443 +31
- Misses 8329 8411 +82
+ Partials 7 6 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
commit: |
Nice to see you again 😀 I've got a few questions first: Which approach are you using on your project? Class or flat? Why not make the class methods behave the same way as flat functions, i.e. require client on every call? |
Class 🙂 (EDIT: Sorry I had written flat before by accident)
Because then I'd have to pass the client in every time, rather than just calling the methods without any options. Slightly more efficient I guess (and I prefer programming that way) |
@chriswiggins I'll need to think about this, and it's not been a priority so far. This goes into the "full SDK" territory which has been discussed many times (e.g. #940). The main issue in this pull request is that it introduces an inconsistent API for flat/class users and I'd rather explore the solution further before possibly committing to this approach. You're totally free to use the fork or even this pull request release in the meantime as I assume you want to use this ASAP. Sorry for the delay here! |
This PR adds an option to the SDK which allows the user to disable the auto-creation of the client in the SDK output. (i.e not doing a
const client = createClient(createConfig());
at the top)Reasoning behind this is we are generating an API client for a microservices based endpoint, so there are multiple SDKs that need to be generated. We want to sit these behind another class where the client is instantiated once, rather than multiple times.
Based on this, when you set
autoCreateClient: false
, the following happens:asClass
is true:client
property is now also required in the optionsI'm not sure I like the
autoCreateClient
variable name, so input would be appreciated!