-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Suggestion
A connector such as the sendgrid loopback connector, is a connector that does not require CRUD commands and it is not a REST data source. This currently seems to make it impossible to run the lb4 service command against such a connector, as the generator will expect a REST datasource.
My suggestion would be to add a new datasource metadata for a connector such as this (one that doesn't require CRUD and is not a REST api), so the service generator is able to recognize it as a valid datasource and make its methods available to controllers.
Use Cases
This will be useful for connecting a service to an email library such as sendgrid, or to utilize other libraries that provide a high-level API for their REST implementations. This includes just about any 3rd party library that is not controlled via REST directly.
Examples
- Create a sendgrid email datasource based on one of the existing sendgrid loopback connectors
- Run the
lb4 servicecommand, to tie this datasource to a service - Inject the service into a controller, to give the user the ability to send emails based on some API request
Acceptance criteria
based on #3288 (comment)
- Modify the logic in
lb4 serviceandlb4 repositoryand when we don't have metadata about the base model used by the connector, then assume the connector is compatible with both services and repositories. Maybe print a hint that we don't know if the connector is compatible.
Hints:
lb4 repositoryis already treating unknown connectors as compatible: https://github.com/strongloop/loopback-next/blob/b0a84b5adc30cac3614ea90e414b59cf76009ecf/packages/cli/generators/repository/index.js#L265-L276lb4 serviceinterprets "unknown" as "incompatible": https://github.com/strongloop/loopback-next/blob/b0a84b5adc30cac3614ea90e414b59cf76009ecf/packages/cli/generators/service/index.js#L191-L196- Changing
lb4 servicetoreturn result !== falseshould fix the issue. - The missing piece is how to write a test to verify the fix. The test should go to file
remote-service.integration.js, take a look at the test forlb4 repositoryfor inspiration here
🎆 Hacktoberfest 2020
Greetings 👋 to all Hacktoberfest 2020 participants!
Here are few tips 👀 to make your start easier, see also #6456:
- Before you start working on this issue, please leave a comment to let others know.
- If you are new to GitHub pull requests, then you can learn about the process in Submitting a pull request to LoopBack 4.
- If this is your first contribution to LoopBack, then please take a look at our Developer guide.
- Feel free to ask for help in
#loopback-contributorschannel, you can join our Slack workspace here.