-
Notifications
You must be signed in to change notification settings - Fork 200
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
feat: ability to configure request handler #1271
Comments
/bounty 250 |
💎 $250 bounty • Tailcall Inc.Steps to solve:
Additional opportunities:
🙏 Thank you for contributing to tailcallhq/tailcall!
|
@Bhavyajain21: The Tailcall Inc. team prefers to assign a single contributor to the issue rather than let anyone attempt it right away. We recommend waiting for a confirmation from a member before getting started. |
@tusharmath why not add a new file instead of new functions on the single file? For large applications, it'd make it more maintainable for the users, and it follows the idea of SRP (as serverless for example, that you have one single entry point to each file implementation). |
Just as suggestions, but anyways, I'll try to implement as it is. |
@ologbonowiwi We could build that into tailcall. But I would leave that up to the developer to figure out how they would like to bundle their js file. They write code in smaller files but ultimately need to expose one file that can be imported and executed. |
@tusharmath // onRequest being a generic handler/interceptor.
function onRequest ({request}) {
// some logic to get path
......
// switch case for path
switch(request_path) {
case "/foo":
return onRequestFoo(request);
break;
case "/bar":
return onRequestBar(request);
break;
default:
// do nothing for others like Baz, just return request back to caller.
return {request} ;
}
}
function onRequestFoo ({request}) {
//
}
function onRequestBar ({request}) {
//
} This is very easy to user. Making onrequest a generic handler/interceptor. What is the advantage the user gets if supposed to configure it in .graphql format? Thanks. |
@tusharmath |
Yes. |
@tusharmath |
Yes. The global one defined in upstream. This is happening right now also. |
Hi @tusharmath, |
/attempt #1271 Options |
Hi @tusharmath, |
Hi @tusharmath, |
/attempt #1271
|
Hi @Rutik7066, |
@Rutik7066: Reminder that in 1 days the bounty will become up for grabs, so please submit a pull request before then 🙏 |
/attempt #1271 I will take up on this important feature to be implemented as quickly as possible.
|
@varshith257: Reminder that in 1 days the bounty will become up for grabs, so please submit a pull request before then 🙏 |
Current
We can only setup one request handler in a JS worker file. This proposal intends to break that restriction
Proposal
In the above implementation when:
foo
,onRequestFoo
is called with the request params.bar
,onRequestBar
is called with the request params.baz
,onRequest
(default handler) is called with the request params.The text was updated successfully, but these errors were encountered: