Skip to content

Commit

Permalink
fix(graphiql-explorer): Adjust env var truthiness logic (#37032)
Browse files Browse the repository at this point in the history
* fix(graphiql-explorer): Adjust env var truthiness logic

* Fix lint for declaration in case block
  • Loading branch information
tyhopp authored Nov 14, 2022
1 parent 57b37ae commit 19dd1c4
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions packages/gatsby-graphiql-explorer/src/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,22 @@ 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,
})
}

Expand Down

0 comments on commit 19dd1c4

Please sign in to comment.