keystonejs / keystone

The superpowered headless CMS for Node.js — built with GraphQL and React
https://keystonejs.com
MIT License
9.13k stars 1.15k forks source link

Bug in default example for NextJS App Router #9298

Open MaxHarrington opened 3 weeks ago

MaxHarrington commented 3 weeks ago

https://github.com/keystonejs/keystone/tree/main/examples/framework-nextjs-app-directory

The build functions for the NextJS app router example are not functioning as expected when cloned from GitHub. When you attempt to build the Keystone interface, it will not compile the GraphQL files, as the script expects the 'pages' file to be located within an 'admin' directory at the root of the project, instead of located within the ~/src/pages/api/[arbitrary routes or pages for the Keystone admin view here].

The build will pick up the GraphQL endpoint as it should when the files are moved to the base directory, but wrapped inside of the admin directory.

image

I've also placed the NextAuth module there, to demonstrate how I figured out this process, and for how future users can embed NextAuth into Keystone using the App Router.

Build error will occur on all versions, it's a problem with file structure.

MaxHarrington commented 3 weeks ago

This should be a pretty trivial fix to improve the developer experience on NextJS quite a bit, I hope I've provided enough information to improve this for others. It is a rather simple movement of files.