Skip to content

Commit 00d7e19

Browse files
committed
rename impersonate API to executeOperation API
1 parent 7dd5dbf commit 00d7e19

File tree

5 files changed

+124
-105
lines changed

5 files changed

+124
-105
lines changed

src/data-connect/data-connect-api-client-internal.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ const API_VERSION = 'v1';
3030
// TODO: CHANGE THIS BACK TO PROD - AUTOPUSH IS ONLY USED FOR LOCAL TESTING BEFORE CHANGES PROPAGATE
3131
/** The Firebase Data Connect backend service URL format. */
3232
const FIREBASE_DATA_CONNECT_SERVICES_URL_FORMAT =
33-
'https://autopush-firebasedataconnect.sandbox.googleapis.com/{version}/projects/{projectId}/locations/{locationId}/services/{serviceId}:{endpointId}';
33+
'https://firebasedataconnect.googleapis.com/{version}/projects/{projectId}/locations/{locationId}/services/{serviceId}:{endpointId}';
3434

3535
/** The Firebase Data Connect backend connector URL format. */
3636
const FIREBASE_DATA_CONNECT_CONNECTORS_URL_FORMAT =
37-
'https://autopush-firebasedataconnect.sandbox.googleapis.com/{version}/projects/{projectId}/locations/{locationId}/services/{serviceId}/connectors/{connectorId}:{endpointId}';
37+
'https://firebasedataconnect.googleapis.com/{version}/projects/{projectId}/locations/{locationId}/services/{serviceId}/connectors/{connectorId}:{endpointId}';
3838

3939
/** Firebase Data Connect service URL format when using the Data Connect emulator. */
4040
const FIREBASE_DATA_CONNECT_EMULATOR_SERVICES_URL_FORMAT =
@@ -146,35 +146,36 @@ export class DataConnectApiClient {
146146
/**
147147
* Executes a GraphQL query with impersonation.
148148
*
149-
* @param options - The GraphQL options, including impersonation details.
149+
* @param options - The GraphQL options. Must include impersonation details.
150150
* @returns A promise that fulfills with the GraphQL response.
151151
*/
152-
public async impersonateQuery<GraphqlResponse, Variables>(
152+
public async executeQuery<GraphqlResponse, Variables>(
153153
options: GraphqlOptions<Variables>
154154
): Promise<ExecuteGraphqlResponse<GraphqlResponse>> {
155-
return this.impersonateHelper(IMPERSONATE_QUERY_ENDPOINT, options);
155+
return this.executeOperationHelper(IMPERSONATE_QUERY_ENDPOINT, options);
156156
}
157157

158158
/**
159159
* Executes a GraphQL mutation with impersonation.
160160
*
161-
* @param options - The GraphQL options, including impersonation details.
161+
* @param options - The GraphQL options. Must include impersonation details.
162162
* @returns A promise that fulfills with the GraphQL response.
163163
*/
164-
public async impersonateMutation<GraphqlResponse, Variables>(
164+
public async executeMutation<GraphqlResponse, Variables>(
165165
options: GraphqlOptions<Variables>
166166
): Promise<ExecuteGraphqlResponse<GraphqlResponse>> {
167-
return this.impersonateHelper(IMPERSONATE_MUTATION_ENDPOINT, options);
167+
return this.executeOperationHelper(IMPERSONATE_MUTATION_ENDPOINT, options);
168168
}
169169

170170
/**
171-
* A helper function to make impersonated GraphQL requests.
171+
* A helper function to execute operations by making requests to FDC's impersonate
172+
* operations endpoints.
172173
*
173174
* @param endpoint - The endpoint to call.
174175
* @param options - The GraphQL options, including impersonation details.
175176
* @returns A promise that fulfills with the GraphQL response.
176177
*/
177-
private async impersonateHelper<GraphqlResponse, Variables>(
178+
private async executeOperationHelper<GraphqlResponse, Variables>(
178179
endpoint: string,
179180
options: GraphqlOptions<Variables>
180181
): Promise<ExecuteGraphqlResponse<GraphqlResponse>> {
@@ -200,8 +201,8 @@ export class DataConnectApiClient {
200201
if (this.connectorConfig.connector === undefined || this.connectorConfig.connector === '') {
201202
throw new FirebaseDataConnectError(
202203
DATA_CONNECT_ERROR_CODE_MAPPING.INVALID_ARGUMENT,
203-
'`connectorConfig.connector` field used to instantiate Data Connect instance \
204-
must be a non-empty string (the connectorId) when calling impersonate APIs.');
204+
`The 'connectorConfig.connector' field used to instantiate your Data Connect
205+
instance must be a non-empty string (the connectorId) when calling executeQuery or executeMutation.`);
205206
}
206207

207208
const data = {

src/data-connect/data-connect-api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export interface ConnectorConfig {
3333

3434
/**
3535
* Name of the Data Connect connector.
36-
* Required for operations that interact with connectors, such as impersonateQuery and impersonateMutation.
36+
* Required for operations that interact with connectors, such as executeQuery and executeMutation.
3737
*/
3838
connector?: string;
3939
}
@@ -59,7 +59,7 @@ export interface GraphqlOptions<Variables> {
5959

6060
/**
6161
* The name of the GraphQL operation.
62-
* Required for operations that interact with connectors, such as impersonateQuery and impersonateMutation.
62+
* Required for operations that interact with connectors, such as executeQuery and executeMutation.
6363
* Required for operations that interact with services, such as executeGraphql, if
6464
* `query` contains multiple operations.
6565
*/

src/data-connect/data-connect.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,17 @@ export class DataConnect {
103103
}
104104

105105
/**
106-
* Executes a pre-defined GraphQL query with impersonation
106+
* Executes a pre-defined GraphQL query with impersonation.
107107
*
108-
* The query must be defined in your Data Connect GQL files.
108+
* The query must be defined in your Data Connect GraphQL files.
109109
*
110110
* @param options - The GraphQL options, must include impersonation details.
111111
* @returns A promise that fulfills with the GraphQL response.
112112
*/
113-
public async impersonateQuery<GraphqlResponse, Variables>(
113+
public async executeQuery<GraphqlResponse, Variables>(
114114
options: GraphqlOptions<Variables>
115115
): Promise<ExecuteGraphqlResponse<GraphqlResponse>> {
116-
return this.client.impersonateQuery(options);
116+
return this.client.executeQuery(options);
117117
}
118118

119119
/**
@@ -124,10 +124,10 @@ export class DataConnect {
124124
* @param options - The GraphQL options, must include impersonation details.
125125
* @returns A promise that fulfills with the GraphQL response.
126126
*/
127-
public async impersonateMutation<GraphqlResponse, Variables>(
127+
public async executeMutation<GraphqlResponse, Variables>(
128128
options: GraphqlOptions<Variables>
129129
): Promise<ExecuteGraphqlResponse<GraphqlResponse>> {
130-
return this.client.impersonateMutation(options);
130+
return this.client.executeMutation(options);
131131
}
132132

133133
/**

0 commit comments

Comments
 (0)