From f68ff65b88665cd3b0af3a7513896e93b40e7dee Mon Sep 17 00:00:00 2001 From: AlexVarchuk Date: Wed, 15 Sep 2021 17:47:24 +0300 Subject: [PATCH] chore:add optional parameter to auth (#368) --- packages/core/src/redocly/index.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/core/src/redocly/index.ts b/packages/core/src/redocly/index.ts index f8158708f..5dfd3db65 100644 --- a/packages/core/src/redocly/index.ts +++ b/packages/core/src/redocly/index.ts @@ -36,7 +36,7 @@ export class RedoclyClient { async verifyToken(accessToken: string, verbose: boolean = false): Promise { if (!accessToken) return false; - const authDetails = await RedoclyClient.authorize(accessToken, verbose); + const authDetails = await RedoclyClient.authorize(accessToken, { verbose }); if (!authDetails) return false; return true; } @@ -91,9 +91,10 @@ export class RedoclyClient { }); } - static async authorize(accessToken: string, verbose: boolean = false) { + static async authorize(accessToken: string, options: { queryName?: string; verbose?: boolean }) { + const { queryName = '', verbose = false } = options; try { - const queryStr = `{ viewer { id } }`; + const queryStr = `query ${queryName}{ viewer { id } }`; return await query(queryStr, {}, { Authorization: accessToken }); } catch (e) {