Skip to content

Consuming Services - Using Query-style APIs - Service.run(SELECT.from(Entity... typing #530

@tsteckenborn

Description

@tsteckenborn

Hey there,

Given an (external service)

/* checksum : 6d384e1372b831278418f83bb53c4ba0 */
@cds.external: true
service SomeExternalService {

  @cds.external        : true
  @cds.persistence.skip: true
  entity SomeEntity {
    key ID         : String(12) not null;
  };
};

I could do the following in another service of mine:

import type SomeExternalService from '#cds-models/SomeExternalService';
import { SomeEntity } from '#cds-models/SomeExternalService';

// ...
// This is wrong, given it would target the wrong service
				const test = await SELECT.from(SomeEntity)
								.where`ID = ${options.ID}`,
// <-- Here `test` would be typed as `SomeEntity`

// This would likely be correct targeting the correct service
				const test2 = await SomeExternalService.run(
							SELECT.from(SomeEntity)
								.where`ID = ${options.ID}`,
						)
// <-- Here `test2` would be typed as `any`

Is that wrong usage on my end, or a current gap?

Related section in the docs https://cap.cloud.sap/docs/node.js/core-services#consuming-services.

Br,
Tobias

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions