Skip to content

Commit ee70018

Browse files
authored
fix: no misleading log message when client is used only for experimental persisted documents (#6606)
1 parent 8a6e60e commit ee70018

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

.changeset/chatty-pandas-clean.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-hive/core': patch
3+
---
4+
5+
Client can be used only for experimental persisted documents

packages/libraries/core/src/client/client.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ export function createHive(options: HivePluginOptions): HiveClient {
1717
let enabled = options.enabled ?? true;
1818

1919
if (enabled === false) {
20-
logIf(options.debug === true, 'plugin is not enabled.', logger.info);
20+
logIf(
21+
options.debug === true &&
22+
// hive client can be used only for persisted documents, without the cdn or usage reporting.
23+
// hence, we dont want a misleading log message below saying that the plugin is disabled
24+
!options.experimental__persistedDocuments,
25+
'Plugin is not enabled.',
26+
logger.info,
27+
);
2128
}
2229

2330
if (!options.token && enabled) {

packages/libraries/core/src/client/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ type OptionalWhenFalse<T, KCond extends keyof T, KExcluded extends keyof T> =
199199
export type HivePluginOptions = OptionalWhenFalse<
200200
{
201201
/**
202-
* Enable/Disable Hive
202+
* Enable/Disable Hive usage reporting
203203
*
204204
* Default: true
205205
*/
@@ -211,7 +211,7 @@ export type HivePluginOptions = OptionalWhenFalse<
211211
*/
212212
debug?: boolean;
213213
/**
214-
* Access Token
214+
* Access Token for usage reporting
215215
*/
216216
token: string;
217217
/**

packages/libraries/core/tests/enabled.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ test("should log that it's not enabled", async () => {
2020
.catch(() => 'ERROR');
2121

2222
expect(logger.info).toHaveBeenCalledWith(
23-
expect.stringContaining(`[hive] plugin is not enabled.`),
23+
expect.stringContaining(`[hive] Plugin is not enabled.`),
2424
);
2525
expect(result).toBe('OK');
2626
});

0 commit comments

Comments
 (0)