Closed marticrespi closed 5 years ago
Hey there,
Does your type appear in the outputted schema ? Generally, this seems like you have just forgotten to re-run the server so that nexus generates the typings, but I may be wrong
Hi @Weakky , After above process I have tried:
prisma generate
then
rm -r ./generated/nexus-prisma
npx nexus-prisma-generate --client ./generated/prisma-client --output ./generated/nexus-prisma
.
After that, I haven't this type in any of these files
schema: path.join(__dirname, './generated/nexus/schema.graphql'),
typegen: path.join(__dirname, './generated/nexus/nexus.ts'),
But without adding the custom mutation, because if I have this part of code uncommented it doesn't compile when i try to serve.
My question is, if I don't add this custom mutation but the new type is declared and included in objectTypes
const, it should be added although is not used?
Many thanks!
AFAIK, nexus doesn't remove unused types, it should remain in the schema even though it's not used. I don't see the point of having a type that isn't used at all though.
prisma generate
and nexus-prisma-generate
have nothing to do with the type error you’re receiving anyway here. The missing type should be generated by nexus
itself at runtime in the nexus.ts
file. Therefore, in order to compile your server, you first need to run your server and let nexus generate the nexus.ts
file, in which it should contain the type definition for that new type you're trying to add.
Only then you'll be able to compile
Well, I was trying to serve with node, and first of all, I transpile all my code to .js and then serving it with node. When I have a change like this, I have to serve first with ts-node
and then nexus is able to create my missing type. Then, I can serve with node, transpiling first and serving after.
Strange..
Hi @Weakky is something about nexus
or nexus-prisma
can do something about? I'm asking to know if I have to close this issue or not.
Thanks!
Hey @marticrespi,
https://github.com/prisma/yoga2 should solve that problem by making sure that your the codegen is regenerated before building your app. It's still WIP though.
Beisdes that, there's an issue here https://github.com/prisma/nexus/issues/77 to discuss about that topic
For now, there's not much we can do to solve that issue, it's fundamentally linked to how nexus works under the hood
Ok, thanks for the info. Closing.
Well, I have a question and I don't know why it doesn't work..
Two weeks ago, I added a custom mutation using nexus adding a new custom type
update-schema.ts
objectTypes/index.ts
And then in my
src/index.ts
And it works perfectly. But now, I want to add a second custom mutation and I repeat the same process..
Add a new file
generated-invoices.ts
Modify my
objectTypes/index.ts
adding this new objectTypeBut when i try to add a new custom mutation, it doesn't recognize this new type.
What am I doing wrong? I have tried to generate prisma and nexus client but it doesn't recognize this new objectType as available,
objectTypes
is an object with two properties, I don't think that it was the problem because myprismaObjectTypes
has the same structure and it works with all its properties hiding some object properties of each one.Thanks!