Skip to content

Commit

Permalink
fix: correctly set enabled value to "true" (#776)
Browse files Browse the repository at this point in the history
Co-authored-by: Kamil Kisiela <kamil.kisiela@gmail.com>
  • Loading branch information
n1ru4l and kamilkisiela authored Dec 15, 2022
1 parent c27beff commit e46b5dd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/honest-lobsters-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-hive/client': patch
---

Use correct default value for 'enabled'.
19 changes: 11 additions & 8 deletions packages/libraries/client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,25 @@ import { version } from './version.js';

export function createHive(options: HivePluginOptions): HiveClient {
const logger = options?.agent?.logger ?? console;
let enabled = options.enabled ?? true;

if (!options.enabled) {
if (enabled === false) {
logIf(options.debug === true, '[hive] is not enabled.', logger.info);
}

if (!options.token && options.enabled) {
options.enabled = false;
if (!options.token && enabled) {
enabled = false;
logger.info('[hive] Missing token, disabling.');
}

const usage = createUsage(options);
const schemaReporter = createReporting(options);
const operationsStore = createOperationsStore(options);
const mergedOptions: HivePluginOptions = { ...options, enabled } as HivePluginOptions;

const usage = createUsage(mergedOptions);
const schemaReporter = createReporting(mergedOptions);
const operationsStore = createOperationsStore(mergedOptions);

function reportSchema({ schema }: { schema: GraphQLSchema }) {
void schemaReporter.report({ schema });
schemaReporter.report({ schema });
}

function collectUsage(args: ExecutionArgs) {
Expand All @@ -36,7 +39,7 @@ export function createHive(options: HivePluginOptions): HiveClient {
}

async function info(): Promise<void> {
if (options.enabled !== true) {
if (enabled === false) {
return;
}

Expand Down

0 comments on commit e46b5dd

Please sign in to comment.