Skip to content

Commit

Permalink
Tweak graphiql setup messages (#9831)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe authored Jan 15, 2024
1 parent 9a43eac commit 3f9a902
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('Graphiql generator tests', () => {
try {
await graphiqlHelpers.generatePayload('dbAuth')
} catch (e) {
expect(e.message).toBe('Require an unique id to generate session cookie')
expect(e.message).toBe('Require a unique id to generate session cookie')
}
})

Expand All @@ -67,7 +67,10 @@ describe('Graphiql generator tests', () => {
await graphiqlHelpers.generatePayload('dbAuth', 'user-id-123')
} catch (e) {
expect(e.message).toBe(
'dbAuth requires a SESSION_SECRET environment variable that is used to encrypt session cookies. Use `yarn rw g secret` to create one, then add to your `.env` file. DO NOT check this variable in your version control system!!'
'dbAuth requires a SESSION_SECRET environment variable that is used ' +
'to encrypt session cookies. Use `yarn rw g secret` to create ' +
'one, then add to your `.env` file. DO NOT check this variable in ' +
'to your version control system!!'
)
}
})
Expand Down
4 changes: 3 additions & 1 deletion packages/cli/src/commands/setup/graphiql/graphiqlHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ const printHeaders = async () => {
export const handler = async ({ provider, id, token, expiry, view }) => {
let payload

const ext = isTypeScriptProject() ? 'ts' : 'js'

const tasks = new Listr(
[
{
Expand All @@ -73,7 +75,7 @@ export const handler = async ({ provider, id, token, expiry, view }) => {
},
},
{
title: 'Generating file in src/lib/generateGraphiQLHeader.{js,ts}...',
title: `Generating file in src/lib/generateGraphiQLHeader.${ext}...`,
task: () => {
const fileName =
token || provider === 'dbAuth'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ const getExpiryTime = (expiry) => {

const getDBAuthHeader = async (userId) => {
if (!userId) {
throw new Error('Require an unique id to generate session cookie')
throw new Error('Require a unique id to generate session cookie')
}

if (!process.env.SESSION_SECRET) {
throw new Error(
'dbAuth requires a SESSION_SECRET environment variable that is used to encrypt session cookies. Use `yarn rw g secret` to create one, then add to your `.env` file. DO NOT check this variable in your version control system!!'
'dbAuth requires a SESSION_SECRET environment variable that is used ' +
'to encrypt session cookies. Use `yarn rw g secret` to create one, ' +
'then add to your `.env` file. DO NOT check this variable in to ' +
'your version control system!!'
)
}

Expand Down

0 comments on commit 3f9a902

Please sign in to comment.