Skip to content
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

Custom service calls surface api - remove isolated method <major> #159

Open
lakardion opened this issue Sep 19, 2023 · 0 comments
Open

Custom service calls surface api - remove isolated method <major> #159

lakardion opened this issue Sep 19, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@lakardion
Copy link
Member

lakardion commented Sep 19, 2023

The problem

One of the options that we want to make available to users is the disableTrailingSlash which removes the trailing slash appending and type layer validation for custom calls (and builtin).
We want to get the right type validation whenever we enable this flag or not. We can do that easily on the createApi method but it is hard to translate this to custom calls.
The main issue I think it is that custom calls are isolated call (createCustomServiceCall) from the api.

We should probably make these two be the same so we don’t mess up on the types there

This is what we could probably do

const api = 
	createApi({client,baseUri,models,options})
// api does not have csc type here...
api.addCustomCall('<name>', { inputShape,outputShape,filtersShape,cb })
//... the custom call (with the right type inference from options)

I am not a big fan of giving a string literal for the name, it would be nice if the user could just define their own name. An alternative would be that they define an object, and addCustomCall takes it and merge it to current custom calls “cache”

api.addCustomCalls({ callName: {inputShape,outputShape,filtersShape,cb }})

I think this one is a better implementation, it does not only give users the power to choose their name to their like on their custom calls but it also allows them to just add multiple custom calls at once, without the need of having to do createCustomServiceCall

Something that comes to mind here is that we might need to rework the type layer for createApi if we want to do something like this. Given that we will need to do type builder pattern to achieve what we're mentioning here. To do so, we will probably have to get rid of the createApi type overloads, which are a bit painful to work with at times.

@lakardion lakardion added the enhancement New feature or request label Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant