Skip to content

Fix seeding errors in exampless/usecase-blog#9830

Merged
dcousens merged 2 commits into
keystonejs:mainfrom
envsecure:fix/usecase-blog-seed-errors
May 6, 2026
Merged

Fix seeding errors in exampless/usecase-blog#9830
dcousens merged 2 commits into
keystonejs:mainfrom
envsecure:fix/usecase-blog-seed-errors

Conversation

@envsecure
Copy link
Copy Markdown
Contributor

Description

This PR fixes the seeding errors in the usecase-blog example reported in #9782.

The issues were:

  1. The Post schema was missing status and publishDate fields which are present in the example data.
  2. The content field (Document type) was receiving a raw string from the example data, causing a GraphQL error.
  3. Lack of safety checks when connecting authors during seeding.

Changes

  • Updated examples/usecase-blog/schema.ts to include status and publishDate fields.
  • Added select to the imported fields in schema.ts.
  • Updated examples/usecase-blog/seed-data.ts to transform the raw content string into a valid Document structure [{ type: 'paragraph', children: [{ text: content }] }].
  • Added a check in seed-data.ts to skip posts if the author is not found, preventing crashes.

Verification

I have manually verified the schema and seed logic changes. Since this is a fix for an example's seed script, it ensures a better onboarding experience for new users.

Resolves #9782

envsecure added 2 commits May 2, 2026 12:52
- Added 'status' and 'publishDate' fields to Post list in schema.ts to match seed data.
- Added 'select' import to core fields.
- Updated seed-data.ts to correctly transform raw content string into Document format.
- Added safety check for author existence during post seeding.

Resolves keystonejs#9782
@envsecure
Copy link
Copy Markdown
Contributor Author

I have updated the branch with a fix for the potential TypeScript errors in seed-data.ts.

Key changes:

  1. Added null checks for authorsList[0] to satisfy strict nullability checks.
  2. Renamed the shadowed authors variable to authorsList to avoid confusion.
  3. Explicitly destructured author from post to ensure it doesn't conflict with the relationship field.

These changes should resolve the "Types" CI check failure.

@dcousens dcousens merged commit 6e9d7ee into keystonejs:main May 6, 2026
48 of 50 checks passed
@dcousens dcousens changed the title fix: resolve seeding errors in usecase-blog example #9782 Fix seeding errors in exampless/usecase-blog May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

examples/usecase-blog errors when running pnpm seed-data

2 participants