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

[Spike] Weakly typed integration with REST/SOAP service #1069

Closed
dhmlau opened this issue Mar 1, 2018 · 3 comments
Closed

[Spike] Weakly typed integration with REST/SOAP service #1069

dhmlau opened this issue Mar 1, 2018 · 3 comments
Assignees
Labels
Milestone

Comments

@dhmlau
Copy link
Member

dhmlau commented Mar 1, 2018

Weakly typed integration - runtime integration

What's involved

  • configure DataSource pointing to the service spec (service metadata) / endpoint (URL to talk to).
  • create service proxy for typescript developers. i.e. collection of methods you can invoke without any type checking. Checking only happens at runtime.
  • Have base class for service that can declare dependencies on DataSource. The service instance will used in the controllers.
  • In LB3, we have a dummy model that associates with the datasource that functions as service proxy. In LB4, we want to get rid of that dummy model.

Questions to answer

Quick spike/ PoC (1 or 2 days)

Coming from discussion with @raymondfeng

@raymondfeng
Copy link
Contributor

@bajtos
Copy link
Member

bajtos commented May 2, 2018

IMO, the pull request #1119 is only a part of the overall story. While it makes it easy to consume services in controllers, it omits other important use cases.

For example, when consuming a service using rest-connector with template-based configuration: as an app developer, I would definitely want to have few smoke tests to verify that my templates work as intended and match the API provided by the service at the other side. I would like to write an integration test that's using only the service (not the full app!), something along the following lines:

import {GeoService} from '../services/geo.service';
import {expect} from '@loopback/testlab';

describe('GeoService', () => {
  let service: GeoService;
  beforeEach(() => service = new GeoService());

  describe('geocode', () => {
    it('returns geo coords for a given address', () => {
      const result = await service.geocode('107 S B St', 'San Mateo', '94401');
      // { lat: 37.5669986, lng: -122.3237495 }
     expect(result.lat).approximately(37.5669986, 0.5);
     expect(result.lng).approximately(-122.3237495, 0.5);
    });
  });
});

There should be also a new CLI command for creating services, this command should:

  • Create the datasource.
  • Create any artifacts needed to register the service with the app for dependency injection. This may require us to implement support for services in @loopback/boot.
  • Create any artifacts needed to write an integration test for the service as I shown above.
  • Ideally, include a scaffolding making it easier for app developers to start writing smoke tests.

@dhmlau
Copy link
Member Author

dhmlau commented May 4, 2018

@raymondfeng , the spike seems to be done. Is this good to close? thanks.

@dhmlau dhmlau closed this as completed May 8, 2018
@shimks shimks added this to the May Milestone milestone May 22, 2018
@bajtos bajtos added the p1 label Aug 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants