Comments (9)
Hi all,
I hope you all review the new version 2.0.0
.
from prisma-tools.
@AhmedElywa This is minimal reproduction https://github.com/vimutti77/Test-PrismaSelect
This is what I found when doing minimal reproduction.
- The error will occur when there are
many-to-many
relations inschema.prisma
.
model Post {
id Int @id @default(autoincrement())
name String
postCategories PostCategory[]
}
model Category {
id Int @id @default(autoincrement())
name String
postCategories PostCategory[]
}
model PostCategory {
postId Int
post Post @relation(fields: [postId], references: [id])
categoryId Int
category Category @relation(fields: [categoryId], references: [id])
@@id([postId, categoryId])
}
- If I add one field in a relation table, the error will disappear.
model PostCategory {
foo String // <--- add this field
postId Int
post Post @relation(fields: [postId], references: [id])
categoryId Int
category Category @relation(fields: [categoryId], references: [id])
@@id([postId, categoryId])
}
- If I remove
new PrismaSelect(info).value
, the error will disappear.
from prisma-tools.
I am also getting a GraphQLError: Syntax Error: Expected Name, found "}"
error after changing PrismaSelect
import
from
import { PrismaSelect } from '@prisma-tools/select'
to
import { PrismaSelect } from '@paljs/plugins'
my query
import { extendType, intArg } from '@nexus/schema'
import prisma from '@database/prisma'
import { PrismaSelect } from '@paljs/plugins'
export const userQuery = extendType({
type: 'Query',
definition: (t) => {
t.field('user', {
type: 'User',
args: {
userId: intArg(),
},
resolve: async (root, args, ctx, info): Promise<any> => {
const user = await prisma.user.findOne({
where: {
id: args.userId,
},
select: new PrismaSelect(info).value.select,
})
return user
},
})
},
})
my package.json
"dependencies": {
"@nexus/schema": "^0.15.0",
"@paljs/plugins": "^1.1.9",
"apollo-server-express": "^2.16.1",
"cross-env": "^7.0.2",
"dotenv-flow": "^3.2.0",
"express": "^4.17.1",
"graphql": "^15.3.0",
"nexus-plugin-prisma": "^0.17.0"
},
"devDependencies": {
"ts-node-dev": "^1.0.0-pre.59",
"tsconfig-paths": "^3.9.0",
"typescript": "^4.0.2"
}
from prisma-tools.
@vimutti77 can you provide a minimal reproduction for the issue?
from prisma-tools.
Yes this because when we create input types for your models this model PostCategory will be empty and this gives an errors
and when you add any field the input type not be empty so the issues are gone
I will look to good fix for this thanks
from prisma-tools.
Same problem i think, is there any solutions?
from prisma-tools.
@ziimakc you also have many to many relation models not have any scalar fields?
from prisma-tools.
@AhmedElywa thanks, works fine now.
from prisma-tools.
Thanks, @ziimakc for the review
from prisma-tools.
Related Issues (20)
- sdlInputs on v5.0.0 onwards HOT 5
- Question: transform outputs from pal g for SDL first
- API EN LOCALHOST FUNCIONA BIEN PERO CUANDO LO SUBO A VERCEL ME DA ERROR DE SERVIDOR NO ME MUESTRA LOS DATOS DE MI BASE DE DATOS
- DeleteOneArgs where field should not be nullable HOT 1
- How to add to an existing project? HOT 1
- pal g only works if the prisma.schema file is saved as LF (linux default) HOT 1
- pal camel-case does not convert enums to camelCase HOT 1
- Support Prisma 5.0.0 version HOT 6
- `__typename` not returned in select HOT 2
- TypeError: Cannot read properties of undefined (reading 'includes')
- Error: pal config file is not found HOT 1
- PrismaSelect - `Record<string, unknown> ` instead of `any`
- [sdl generator] Error when model name is in lower case HOT 1
- Convert to Camel case breaks when tables start with same name
- problems using arguments in a subquery
- _count doesn't accept arguments
- Aggregate resolver return type is wrong
- Utils has some Typescript errors
- Test in utils fails on Windows
- VS Code settings should include PNPM as the package manager
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prisma-tools.