Open embpdaniel opened 5 years ago
At the moment, we use "baseModel": "Model",
to tell a connector is for service apis. See https://github.com/strongloop/loopback-workspace/blob/master/available-connectors.json
@raymondfeng the problem is that the sendgrid connector is not listed in available-connectors file.
IMO, it's not reasonable to expect all community-maintained connectors to be listed in that file.
For the short term, I am proposing to modify the logic in lb4 service
and lb4 repository
and 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.
I think the first part can be easily accomplished by changing the following line to return true
instead of null
:
For longer term, I think we should replace available-connectors file with a decentralized approach:
loopback-connector
or two keywords loopback
and `connector. Example query: https://api.npms.io/v2/search?q=keywords:loopback+connector&size=250 finds 180 connector-like packages, strangely enough our own mysql connector is not included.package.json
file and can be fetched e.g. via npmjs registry get package API. I think a better option is to use pacote, which is npm client library that leverages npm's cache to save network requests.Any Solution regarding this. Stuck in sending email using sendgrid in loopback 4
@AsjadMahmood you can use the following workaround:
lb4 datasource
using a supported service connector first, e.g. REST. Enter any valid configuration, you will change this later.lb4 service
.sendgrid
connector. Update your project dependencies - remove the connector installed by lb4 datasource
and add your connector.
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
lb4 service
command, to tie this datasource to a serviceAcceptance criteria
based on https://github.com/strongloop/loopback-next/issues/3288#issuecomment-507628571
lb4 service
andlb4 repository
and 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 repository
is already treating unknown connectors as compatible: https://github.com/strongloop/loopback-next/blob/b0a84b5adc30cac3614ea90e414b59cf76009ecf/packages/cli/generators/repository/index.js#L265-L276lb4 service
interprets "unknown" as "incompatible": https://github.com/strongloop/loopback-next/blob/b0a84b5adc30cac3614ea90e414b59cf76009ecf/packages/cli/generators/service/index.js#L191-L196lb4 service
toreturn result !== false
should fix the issue.remote-service.integration.js
, take a look at the test forlb4 repository
for inspiration here🎆 Hacktoberfest 2020
Greetings :wave: to all Hacktoberfest 2020 participants!
Here are few tips 👀 to make your start easier, see also #6456:
#loopback-contributors
channel, you can join our Slack workspace here.