Skip to content

fix(dc): Favor 'service' over 'serviceId' in FDC connectorConfig #2890

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/data-connect/data-connect-api-client-internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ export class DataConnectApiClient {
...(options?.operationName && { operationName: options?.operationName }),
...(options?.impersonate && { extensions: { impersonate: options?.impersonate } }),
};
return this.getUrl(API_VERSION, this.connectorConfig.location, this.connectorConfig.serviceId, endpoint)
// N.B. Admin SDK originally used "serviceId" whereas the autogenerated SDKs provide "service".
const service = 'service' in this.connectorConfig ? this.connectorConfig.service : this.connectorConfig.serviceId;
return this.getUrl(API_VERSION, this.connectorConfig.location, service, endpoint)
.then(async (url) => {
const request: HttpRequestConfig = {
method: 'POST',
Expand Down
12 changes: 9 additions & 3 deletions src/data-connect/data-connect-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,23 @@ import { DecodedIdToken } from '../auth/token-verifier';
/**
* Interface representing a Data Connect connector configuration.
*/
export interface ConnectorConfig {
export type ConnectorConfig = {
/**
* Location ID of the Data Connect service.
*/
location: string;

} & ({
/**
* Service ID of the Data Connect service.
* @deprecated use 'service' instead
*/
serviceId: string;
}
} | {
/**
* Service ID of the Data Connect service.
*/
service: string;
});

/**
* Interface representing GraphQL response.
Expand Down
5 changes: 4 additions & 1 deletion src/data-connect/data-connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ export class DataConnectService {
}

getDataConnect(connectorConfig: ConnectorConfig): DataConnect {
const id = `${connectorConfig.location}-${connectorConfig.serviceId}`;
// N.B. For a while, Admin used "serviceId" as its field even though the autogenerated
// SDKs created "service". Let's reconcile.
const service = 'service' in connectorConfig ? connectorConfig.service : connectorConfig.serviceId;
const id = `${connectorConfig.location}-${service}`;
const dc = this.dataConnectInstances.get(id);
if (typeof dc !== 'undefined') {
return dc;
Expand Down
2 changes: 1 addition & 1 deletion src/data-connect/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export {
* ```javascript
* const connectorConfig: ConnectorConfig = {
* location: 'us-west2',
* serviceId: 'my-service',
* service: 'my-service',
* };
*
* // Get the `DataConnect` service for the default app
Expand Down
Loading