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

fix(cli): regenerate prisma schema during keystone prisma .. commands #8698

Merged
merged 6 commits into from
Aug 13, 2023
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
5 changes: 5 additions & 0 deletions .changeset/fix-frozen-prisma.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-6/core': major
---

Changes `keystone prisma` behaviour to not generate Typescript types and prisma schema when using `--frozen`
14 changes: 11 additions & 3 deletions packages/core/src/scripts/prisma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { createSystem } from '../lib/createSystem';
import {
getBuiltKeystoneConfiguration,
generateTypescriptTypesAndPrisma,
validatePrismaAndGraphQLSchemas,
generatePrismaAndGraphQLSchemas,
validatePrismaAndGraphQLSchemas
} from '../artifacts';
import { getEsbuildConfig } from '../lib/esbuild';
import { ExitError } from './utils';
Expand All @@ -19,8 +20,15 @@ export async function prisma(cwd: string, args: string[], frozen: boolean) {
// TODO: this cannot be changed for now, circular dependency with getSystemPaths, getEsbuildConfig
const config = getBuiltKeystoneConfiguration(cwd);
const { graphQLSchema } = createSystem(config);
await validatePrismaAndGraphQLSchemas(cwd, config, graphQLSchema);
await generateTypescriptTypesAndPrisma(cwd, config, graphQLSchema);
Copy link
Member

@dcousens dcousens Jul 18, 2023

Choose a reason for hiding this comment

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

Thinking about this with @borisno2, it is kind of weird that we did generateTypescriptTypesAndPrisma here at all.

The validatePrismaAndGraphQLSchemas protects the developer in production by respecting the existing schemas, but then we go ahead and re-generate the types and Prisma, which is weird for production.

I don't think we should keep generateTypescriptTypesAndPrisma and users should either just run keystone dev or keystone build --no-ui before they use keystone prisma ....

Unfortunately, however you look at this, this is a breaking change, we do want to fix it @pahaz, but maybe the best workaround for you in the interim is to use keystone build --no-ui before your migrate dev command.


if (frozen) {
await validatePrismaAndGraphQLSchemas(cwd, config, graphQLSchema);
console.log('✨ GraphQL and Prisma schemas are up to date');
} else {
await generatePrismaAndGraphQLSchemas(cwd, config, graphQLSchema); // TODO: rename to generateSchemas (or similar)
console.log('✨ Generated GraphQL and Prisma schemas');
await generateTypescriptTypesAndPrisma(cwd, config, graphQLSchema); // TODO: rename to generatePrismaClientAndTypes (or similar)
}

const result = await execa('node', [require.resolve('prisma'), ...args], {
cwd,
Expand Down
Loading