Questions tagged [nexus-prisma]
62 questions
2
votes
1 answer
Add custom GraphQL resolvers and types into Prisma/Nexus schema
Using: TypeScript, Prisma, MySQL, GraphQLServer, ApolloClient, building schema this way:
const schema = makePrismaSchema({
// Provide all the GraphQL types we've implemented
types: [Query, Mutation, User, Post],...
And then:
const server =…

Tomas Randus
- 2,127
- 4
- 29
- 38
1
vote
0 answers
Prisma solution to avoid n+1 with findUnique performs mutiple select id from table
I am using apollo server and nexus with Prisma.
I followed this guide to avoid n+1 problem:
https://www.prisma.io/docs/guides/performance-and-optimization/query-optimization-performance.
This is my User type:
const User = objectType({
name:…

Naor
- 23,465
- 48
- 152
- 268
1
vote
2 answers
get a nested email field that is part of another model in prisma?
i have schema that looks like:
schema.prisma
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "sqlite"
url = "file:./dev.db"
}
model User {
id String @id @default(cuid())
email String? @unique
…

deadcoder0904
- 7,232
- 12
- 66
- 163
1
vote
2 answers
Advanced GroupBy and Aggregation in GraphQL using Nexus (+Prisma)
I have a use case at the moment where I need to build a query that can either return a list of objects or return a list of objects grouped and aggregated for a dashboard. While I could spend a lot of time building a unique -GroupedByObject for each…

Lloyd Richards
- 330
- 3
- 12
1
vote
0 answers
Adding many relation fields to Prisma 3
This is my quite simple Prisma 3 schema for a dashboard application
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id String @id…

Igniter
- 857
- 9
- 24
1
vote
0 answers
nexus-prisma with jest: running tests error
I am using prisma with nexus-prisma and I am trying to run tests. Without success. My package.json.
Thanks for your help!
"@prisma/client": "^2.30.1",
"nexus": "^1.1.0",
"nexus-prisma": "^0.33.0",
"jest": "^27.1.0"
"jest": {
"setupFiles": [
…

Manuel Bichler
- 507
- 5
- 10
1
vote
0 answers
How to prevent/ignore a field being sent during a nexus graphql mutation of relation field?
I use combination of Apollo Server, Nexus and Prisma for my graphql server. I wanted to create a user with multiple posts. But the user shouldn't be allowed to set the isPublished field in the posts. When creating the post directly I can use…

user1945290
- 11
- 1
1
vote
1 answer
Recursively convert object items that are equal to null to undefined
So I am connecting Prisma orm to Graphql Nexus and need to convert graphql args that are T | null | undefined to T | undefined that is accepted by Prisma.
Here is how it is done inside Nexus…

Nenad
- 231
- 3
- 15
1
vote
2 answers
Correct way to define contextType in NexusJS while using NextJS
I trying to get Prisma and Nexus working with NextJS, but I am having some trouble defining the contextType in the GraphQL schema.
I define the schema like this:
export const schema = makeSchema({
types: [Query, User, Mutation],
contextType: {
…

slinden
- 953
- 1
- 11
- 24
1
vote
1 answer
How to search M to N relationship in prisma?
I'm working on project with prisma nowadays.
I designed m to n relationship table. Below is my code.
schema.prisma
model Artists {
id Int @id @default(autoincrement())
artistName String?
Albums …

lcpnine
- 477
- 1
- 7
- 16
1
vote
1 answer
How to replace the null values with undefined (in object properties) only in case of not assignable types?
type GraphQLInput = {
email: string;
age?: null | number | undefined;
height?: null | number | undefined;
}
type PrismaPerson = {
email: string;
age: number | undefined;
height: null | number;
}
let input: GraphQLInput = {
email:…

robert.little
- 410
- 3
- 13
1
vote
3 answers
Prisma and ApolloClient: Prevent overwriting the include conditions at the backend by the frontend for relations
I have a problem, thx for any help.
With prisma we can use include with where conditions for models with a relation. If I make include conditions I get the right result. If I return it to the frontend it gets overwritten. I want to return exact my…

Tölz
- 766
- 2
- 8
- 18
1
vote
1 answer
Prisma: Most performant way to query for sub relations
I want to query for posts and for each post I wan't just the like from the current user.
I have 2 solutions and both are working. But which one is better? Or are there better solutions?
Frontend: React + ApolloClient
Backend: Primsa2 + Graphql…

Tölz
- 766
- 2
- 8
- 18
1
vote
1 answer
How to use JSON type in prisma, graphql nexus framework?
Please for example how to use JSON type
generator prisma_client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
model t {
id Int @default(autoincrement()) @id
val Json?
}
I need…

Daniel
- 7,684
- 7
- 52
- 76
1
vote
1 answer
Get data from secondary table in Prisma2
I have a User table that contains user data. I also have a Relationship table that contains a parent_id and a child_id as well as the incrementing id. Each Parent can have many Children and I am trying to retrieve the array of children using the…

Tristan
- 341
- 4
- 17