Questions tagged [nexus-prisma]
62 questions
8
votes
2 answers
How to use DECIMAL(10,2) in prisma migrate tool?
I need save DECIMAL(10,2) in database. In MySQL there is DECIMAL type.
MySQL docs:
https://dev.mysql.com/doc/refman/8.0/en/fixed-point-types.html
Prisma 2.0 docs:
https://www.prisma.io/docs/reference/database-connectors/mysql
Possible Prisma…

Daniel
- 7,684
- 7
- 52
- 76
7
votes
1 answer
Nexus-prisma: order nested connections
What is the best way to keep order of nested objects in the schema.
My schema:
type Article {
id: ID! @id
pages: [Page!]!
}
type Page {
id: ID! @id
}
This is how I'm trying to sort the pages(unsuccessfully):
updateArticle({
variables:…

Tomas Randus
- 2,127
- 4
- 29
- 38
5
votes
3 answers
Polymorphism in Prisma Schema - Best practices?
This is more a design question than a coding question. Suppose the following schema:
// schema.prisma
// Solution 1
model Entity {
id Int @id @default(autoincrement())
attrs EntityAttr[]
}
model EntityAttr {
id Int …

buzzysin
- 311
- 3
- 12
5
votes
3 answers
Prisma2 Error: Invalid `prisma.post.create()` invocation: Unknown arg `tags` in data.tags for type PostUncheckedCreateInput
I want to create a post with a list of tags attached to it. The models are connected many-to-many (one post can have several tags, and one tag can have several posts in it).
Here are my prisma models:
model Post {
id String @id @default(cuid())
…

lumenwrites
- 1,287
- 4
- 18
- 35
5
votes
2 answers
Subscriptions not working with Prisma 2 and Nexus?
Subscriptions with Nexus are undocumented but I searched Github and tried every example in the book. It's just not working for me.
I have cloned Prisma2 GraphQL boilerplate project & my files are as follows:
prisma/schema.prisma
datasource db {
…

deadcoder0904
- 7,232
- 12
- 66
- 163
4
votes
1 answer
Handling file upload with nexus-prisma graphql
I'm trying to upload a file from my frontend app to my server
but I keep getting this weird error and have no idea why it's happening.
Error is frontend:
Variable "$file" got invalid value {}; Expected type Upload. Upload value invalid.
Error in…

Raji Hawa
- 156
- 1
- 6
4
votes
2 answers
Input Object type XXX must define one or more fields in prisma 2.0
I have the following schema.prisma file:
model Account {
id Int @default(autoincrement()) @id
name String
transactions Transaction[]
}
model Transaction {
id Int @default(autoincrement()) @id
accountId Int
account Account…

Daniel
- 7,684
- 7
- 52
- 76
4
votes
1 answer
How to do a nested mutation resolver with nexus-prisma
I have the following datamodel:
type Job {
// ...
example: String
selections: [Selection!]
// ...
}
type Selection {
...
question: String
...
}
I define my object type so:
export const Job = prismaObjectType({
name:…

Trufa
- 39,971
- 43
- 126
- 190
3
votes
0 answers
How can I sort items by custom value in Prisma? (trying to implement "sort by hot" like on Hacker News or Reddit)
I'm trying to implement "sort by hot" similar to what HackerNews/Reddit do, as described here.
I want to calculate the rank of a post like so:
const age = new Date() - createdAt
const gravity = 1.8
const rankScore = (score - 1) / (age + 2) **…

lumenwrites
- 1,287
- 4
- 18
- 35
3
votes
1 answer
Cannot get ts-node to compile code with optional chaining
Why does it do that? I thought I had it working, but after writing some code with ?. syntax in it, it stopped working. I tried to update involved dependencies but to no avail.
Bellow is hopefully everything relevant. (Command is npm run…

Akxe
- 9,694
- 3
- 36
- 71
3
votes
2 answers
prisma2 migrate Error: There are more migrations in the database than locally
I am building backend app using prisma2 + typescript + nexus + graphql-yoga. I have defined my schema now while trying to save migrate by running command:
prisma2 migrate save --name "init" --experimental
Getting the following error.
Error: There…

ganesh deshmukh
- 314
- 4
- 17
2
votes
2 answers
How can I leverage Prisma's implicit relations to create the following relation? (one-many, many-many, one-one)
I'm learning Prisma,
I want to leverage Prisma's Implicit relations as much as possible for the following relation (and later I want to use nexus for writing queries):
1 User can belong to Many Conversations (as it's participant)
1 Conversation…

Daniel Hoops
- 41
- 3
2
votes
1 answer
Prisma 1 to 2 migration issue: P4001 The introspected database was empty
So, I've been attempting to run the introspection process on my existing dastabase as follows:
npx prisma introspect
and received the following error trace:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program…

TheoG
- 1,498
- 4
- 30
- 54
2
votes
1 answer
Combining Typescript generics with any without losing type
This is related to a plugin I am building for the @nexus/schema library (type-safe GraphQL), but it is purely a Typescript typing issue.
I have a rules system where all my rules are derived form this interface:
interface Rule

Sytten
- 322
- 1
- 8
2
votes
1 answer
What is the best way to expose total number of Pages in Prisma2 using nexus?
I am switching to Prisma2 using nexus and cannot find a good way to implement pagination - a skip type will work fine. I could find a good way to implement it on the array, so what I ended up is added a computed field total on the type.
export…

Svitlana
- 2,324
- 4
- 22
- 31