I didn't manage to find a good way that explains t...
# orm-help
m
I didn't manage to find a good way that explains the setup of nexus (the framework) with prisma. I don't get where is the entrypoint, and get typescript errors with every t.model(it says that it doesn't have the .model part). Do someone have some tips for that?
n
Hey Matheus 👋 I've recently given a talk where I'm showing how to set up Prisma with Nexus from scratch. The part of about Nexus in my talk starts

here

. Let me know if that helps! 🙂
m
Thank you! The team already decided to not use it since we had some issues with it and the app might get pretty big. But I'll use that as a learning tool for nexus. Thanks!
n
Ah I see, thanks for the update! 🙂 Can you elaborate a bit on the issues the team had with Nexus? Would love to learn more about the shortcomings you've identified with Nexus!
m
Initially I had issues running the very first command
npx nexus
, it took me some time to troubleshoot because I thought that I had an older version or
@nexus/schema
installed and those were the reasons. But in the end I found out that it doesn't work with windows. It gives me the error:
The global Nexus CLI you invoked could not hand off to your project-local one becuase it wasn't on disk
Then, me and a coworker tried implementing it by looking at an example in the prisma repo and it seems that this was an older version of nexus, which then became nexus/schema. And this mix of information here and there made us not feel that we won't always find the right documentation for the version we have. So we went and tried using the framework instead and that's when I got the
npx nexus
error thing, and my friend which uses mac had to run the commands. The getting started tutorial doesn't explain much of what the npx nexus do, it just says "run the command", "now change this part". Instead of saying "run the command, it will do this and that", "now go, or create the file at the directory X" It doesn't say where is the entrypoint nor does it explain that there's no entrypoint and it tries to find the file with the import automatically. Then we didn't like much about that because we like to run crons and other stuff in the entrypoint. So we went with
@nexus/schema
. But we always felt that this was going to be left behind/not have features added because the work had been shifted to nexus "the framework". And when we tried it, with the most up to date prisma, we had the issues I told. Where typescript was saying that the variable
t
didn't have a variable
.model
, even though we had the prisma plugin installed(we didn't know which one was right, the
prisma-plugin
or
nexus-plugin-prisma
/schema, and neither worked), so we just gave up and used SDL-first then, which gives us more control. Even using that we're having some issues. In our root
query
, we have a query that returns a type, for example
User
. And user has a property called parent, also of type
User
, defined in the SDL. Our graphql code generator is expecting that the root resolver
query
, when returning a list, return that parent. But when we do
ctx.db.findMany();
. The
parent
in the return of that findMany will be of type
string
, because prisma gives us the ID. And that's fine, because we have the
User
resolver which will return the correct parent object. But the code generator forces that the root
Query
had the correct parent, and we're having issue with that. So we'd like more prisma2 tutorials/examples with typescript with sdl and strictly typed resolvers. Well, sorry for the wall of text haha.
Just to update you we did manage to make
@nexus/schema
work. We can't use
nexus
for now due to the windows compatibility
n
Thanks so much for the writeup, this is super helpful! 🙏
💪 1