Matheus Assis
05/26/2020, 12:02 PMMatheus Assis
05/26/2020, 12:10 PMnikolasburk
Matheus Assis
05/26/2020, 12:34 PMnpx 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.Matheus Assis
05/26/2020, 8:49 PM@nexus/schema
work. We can't use nexus
for now due to the windows compatibilitynikolasburk