Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak graphiql setup messages #9831

Merged
merged 1 commit into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading