-
Notifications
You must be signed in to change notification settings - Fork 985
Add generics to httpsCallable #4466
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
|
Size Analysis Report |
fad56ab to
d7692c2
Compare
| it('scalars', async () => { | ||
| const functions = createTestService(app, region); | ||
| const func = httpsCallable(functions, 'scalarTest'); | ||
| const func = httpsCallable<number, number>(functions, 'scalarTest'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe at least the request (and maybe the response as well) must be objects. Scalars may not be allowed by the server-side implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a live test that sends a number to the server and successfully gets a number response so it seems to work, unless I'm misunderstanding. To make sure, I also created a new onCall function that logged a number sent to it and returned a number and tried it from a test app and it seems to work:
exports.numberTest = functions.https.onCall((data) => {
console.log(data, typeof data);
return(44);
});
Let me know if I misunderstood.
14dbd51 to
4b7a353
Compare
4b7a353 to
b4c1b5d
Compare
Add
RequestDataandResponseDatagenerics tohttpsCallable.RequestDatais the arg provided to the callable function (only one allowed). The callable function returns a promise with adatafield, andRequestDatadescribes whatever is in that data field.Used the generics in a couple of
httpsCallabletests as a check to make sure the typing works, and left them out of some tests to make sure it also works if they are omitted.