Giter VIP home page Giter VIP logo

Comments (9)

AhmedElywa avatar AhmedElywa commented on May 16, 2024 2

Hi all,
I hope you all review the new version 2.0.0.

from prisma-tools.

vimutti77 avatar vimutti77 commented on May 16, 2024 1

@AhmedElywa This is minimal reproduction https://github.com/vimutti77/Test-PrismaSelect

This is what I found when doing minimal reproduction.

  1. The error will occur when there are many-to-many relations in schema.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])
}
  1. 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])
}
  1. If I remove new PrismaSelect(info).value, the error will disappear.

from prisma-tools.

vimutti77 avatar vimutti77 commented on May 16, 2024

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.

AhmedElywa avatar AhmedElywa commented on May 16, 2024

@vimutti77 can you provide a minimal reproduction for the issue?

from prisma-tools.

AhmedElywa avatar AhmedElywa commented on May 16, 2024

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.

ziimakc avatar ziimakc commented on May 16, 2024

Same problem i think, is there any solutions?

from prisma-tools.

AhmedElywa avatar AhmedElywa commented on May 16, 2024

@ziimakc you also have many to many relation models not have any scalar fields?

from prisma-tools.

ziimakc avatar ziimakc commented on May 16, 2024

@AhmedElywa thanks, works fine now.

from prisma-tools.

AhmedElywa avatar AhmedElywa commented on May 16, 2024

Thanks, @ziimakc for the review

from prisma-tools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.