From bfde4328a08db5d8c4d54f21cceaa389e3426323 Mon Sep 17 00:00:00 2001 From: Ty Hopp Date: Mon, 14 Nov 2022 12:02:49 +0800 Subject: [PATCH 1/2] fix(graphiql-explorer): Adjust env var truthiness logic --- packages/gatsby-graphiql-explorer/src/app.jsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/gatsby-graphiql-explorer/src/app.jsx b/packages/gatsby-graphiql-explorer/src/app.jsx index b93852c6361c1..4641376ab00d4 100644 --- a/packages/gatsby-graphiql-explorer/src/app.jsx +++ b/packages/gatsby-graphiql-explorer/src/app.jsx @@ -108,9 +108,21 @@ const App = ({ initialExternalFragments }) => { const fetchData = async () => { const result = await graphQLIntrospection() + let { enableRefresh, refreshToken } = result.extensions + + switch (typeof enableRefresh) { + case `string`: + const lowerCased = enableRefresh.toLowerCase() + enableRefresh = lowerCased === `1` || lowerCased === `true` + break + case `number`: + enableRefresh = enableRefresh > 0 + break + } + setRefreshState({ - enableRefresh: !!+result.extensions.enableRefresh, - refreshToken: result.extensions.refreshToken, + enableRefresh, + refreshToken, }) } From d8395baefd6a49c2ca0a686f08944953965308b2 Mon Sep 17 00:00:00 2001 From: Ty Hopp Date: Mon, 14 Nov 2022 12:15:22 +0800 Subject: [PATCH 2/2] Fix lint for declaration in case block --- packages/gatsby-graphiql-explorer/src/app.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/gatsby-graphiql-explorer/src/app.jsx b/packages/gatsby-graphiql-explorer/src/app.jsx index 4641376ab00d4..297245917f5db 100644 --- a/packages/gatsby-graphiql-explorer/src/app.jsx +++ b/packages/gatsby-graphiql-explorer/src/app.jsx @@ -111,10 +111,11 @@ const App = ({ initialExternalFragments }) => { let { enableRefresh, refreshToken } = result.extensions switch (typeof enableRefresh) { - case `string`: + case `string`: { const lowerCased = enableRefresh.toLowerCase() enableRefresh = lowerCased === `1` || lowerCased === `true` break + } case `number`: enableRefresh = enableRefresh > 0 break