Skip to content

Commit

Permalink
Add isVerbose flag to createExpressServer (#5017)
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie authored Mar 5, 2021
1 parent e22e7ab commit 0cd5acb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .changeset/lazy-snails-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@keystone-next/keystone': minor
'@keystone-next/test-utils-legacy': patch
---

Added an `isVerbose` flag to `createExpressServer` to allow it to be run silently during tests.
9 changes: 5 additions & 4 deletions packages-next/keystone/src/lib/createExpressServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ export const createExpressServer = async (
graphQLSchema: GraphQLSchema,
createContext: CreateContext,
dev: boolean,
projectAdminPath: string
projectAdminPath: string,
isVerbose: boolean = true
) => {
const server = express();

Expand All @@ -77,13 +78,13 @@ export const createExpressServer = async (

const sessionStrategy = config.session ? config.session() : undefined;

console.log('✨ Preparing GraphQL Server');
if (isVerbose) console.log('✨ Preparing GraphQL Server');
addApolloServer({ server, graphQLSchema, createContext, sessionStrategy });

if (config.ui?.isDisabled) {
console.log('✨ Skipping Admin UI app');
if (isVerbose) console.log('✨ Skipping Admin UI app');
} else {
console.log('✨ Preparing Admin UI Next.js app');
if (isVerbose) console.log('✨ Preparing Admin UI Next.js app');
server.use(
await createAdminUIServer(config.ui, createContext, dev, projectAdminPath, sessionStrategy)
);
Expand Down
2 changes: 1 addition & 1 deletion packages/test-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ async function setupFromConfig({
''
);

const app = await createExpressServer(config, graphQLSchema, createContext, true, '');
const app = await createExpressServer(config, graphQLSchema, createContext, true, '', false);

return { keystone, context: createContext().sudo(), app };
}
Expand Down

1 comment on commit 0cd5acb

@vercel
Copy link

@vercel vercel bot commented on 0cd5acb Mar 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.