Skip to content

Commit 52a18d7

Browse files
committed
remove internal client from operation refs
1 parent ae8096a commit 52a18d7

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/data-connect/data-connect.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,16 @@ export class DataConnect {
161161
return this.client.upsertMany(tableName, variables);
162162
}
163163

164+
/** @internal */
165+
public executeQuery<Data, Variables>(options: GraphqlOptions<Variables>): Promise<ExecuteGraphqlResponse<Data>> {
166+
return this.client.executeQuery<Data, Variables>(options);
167+
}
168+
169+
/** @internal */
170+
public executeMutation<Data, Variables>(options: GraphqlOptions<Variables>): Promise<ExecuteGraphqlResponse<Data>> {
171+
return this.client.executeMutation<Data, Variables>(options);
172+
}
173+
164174
/**
165175
* Create a reference to a specific "instance" of a named query.
166176
* @param name Name of query
@@ -191,7 +201,7 @@ export class DataConnect {
191201
`The 'connectorConfig.connector' field used to instantiate your Data Connect
192202
instance must be a non-empty string (the connectorId) when creating a queryRef.`);
193203
}
194-
return new QueryRef(this, options, this.client);
204+
return new QueryRef(this, options);
195205
}
196206

197207
/**
@@ -230,7 +240,7 @@ export class DataConnect {
230240
`The 'connectorConfig.connector' field used to instantiate your Data Connect
231241
instance must be a non-empty string (the connectorId) when creating a mutationRef.`);
232242
}
233-
return new MutationRef(this, options, this.client);
243+
return new MutationRef(this, options);
234244
}
235245
}
236246

@@ -253,7 +263,6 @@ abstract class OperationRef<Data, Variables> {
253263
constructor(
254264
public readonly dataConnect: DataConnect,
255265
public readonly options: GraphqlOptions<Variables>,
256-
protected readonly client: DataConnectApiClient
257266
) {
258267
if (typeof options.operationName === 'undefined') {
259268
throw new FirebaseDataConnectError(
@@ -273,7 +282,7 @@ abstract class OperationRef<Data, Variables> {
273282

274283
class QueryRef<Data, Variables> extends OperationRef<Data, Variables> {
275284
async execute(): Promise<QueryResult<Data, Variables>> {
276-
const { data } = await this.client.executeQuery<Data, Variables>(this.options);
285+
const { data } = await this.dataConnect.executeQuery<Data, Variables>(this.options);
277286
return {
278287
ref: this,
279288
data: data,
@@ -285,7 +294,7 @@ class QueryRef<Data, Variables> extends OperationRef<Data, Variables> {
285294

286295
class MutationRef<Data, Variables> extends OperationRef<Data, Variables> {
287296
async execute(): Promise<MutationResult<Data, Variables>> {
288-
const { data } = await this.client.executeMutation<Data, Variables>(this.options)
297+
const { data } = await this.dataConnect.executeMutation<Data, Variables>(this.options)
289298
return {
290299
ref: this,
291300
data: data,

0 commit comments

Comments
 (0)