https://www.prisma.io/ logo
Join Slack
Powered by
# orm-help
  • r

    Rodrigo

    06/27/2020, 5:20 PM
    Hi, due to a blackout here I wasn't able to watch the workshop I signed up for in Prisma day (Building a type-safe GraphQL server with Nexus and Prisma). I saw in the youtube channel that only day two is up. Will the workshops from day one be uploaded to youtube as well? Thanks!!
  • s

    Sameer kashyap

    06/28/2020, 9:40 AM
    Can I connect
    prisma
    to
    MongoDB
    ? or is it not supported yet?
    d
    • 2
    • 3
  • m

    Marco Tedone

    06/28/2020, 3:43 PM
    Hi thrilled to be here
  • s

    Stefan Trivuncic

    06/28/2020, 10:47 PM
    With
    Prisma 2
    , how is everyone’s workflow in terms of running a local database locally via
    PostgreSQL
    ? Do you still run a docker container?
    r
    • 2
    • 7
  • p

    Philipp Rajah Moura Srivastava

    06/29/2020, 1:58 AM
    Hey all, so I’m trying to get prisma 1 working with subscriptions. I followed the example and it looks like this.
    Copy code
    const userUpdates = {
      subscribe: async (parent, { id }, context, info) => {
        // Function: userUpdates, a resolver function that subscribes to
        // any changes made to a user.
        //
        // Parameter(s):
        //
        //   parent, args, context, info - default prisma parameters
        //   args is an object containing the user Id
        //
        // Return Value(s):
        //
        //   a subscription
         // node: { id_contains: id },
    
        return context.prisma.$subscribe.user({ node: { id: id }, mutation_in: ["UPDATED"] }).node();
      },
      resolve: (payload) => {
        //returning payload
        console.log("hi", "two")
        return payload;
      }
    }
  • p

    Philipp Rajah Moura Srivastava

    06/29/2020, 1:59 AM
    However I’m getting this error when I update a user
  • p

    Philipp Rajah Moura Srivastava

    06/29/2020, 1:59 AM
    Copy code
    {
      "errors": [
        {
          "message": "Cannot read property 'get' of undefined",
          "locations": [
            {
              "line": 2,
              "column": 3
            }
          ],
          "path": [
            "userUpdates"
          ]
        }
      ],
      "data": null
    }
  • p

    Philipp Rajah Moura Srivastava

    06/29/2020, 2:00 AM
    I’m using prisma-client-library 1.34.10
  • p

    Philipp Rajah Moura Srivastava

    06/29/2020, 2:01 AM
    I’m aware you can use PubSub from graphql-yoga to implement subscriptions so should I go that route or does anyone know a fix to this?
  • c

    Christoph Dietrich

    06/29/2020, 11:02 AM
    Hey all, did someone has a good example to use file upload with nexus?
    r
    s
    • 3
    • 4
  • a

    Ashiqur Rahman

    06/29/2020, 12:53 PM
    Copy code
    Error in Prisma Client request: 
    
    Error: 
    Invalid `prisma.order.findMany()` invocation:
    
    PANIC: Application logic invariant error: received null value for field post which may not be null
        at PrismaClientFetcher.request (/home/ashik/.cache/prisma/studio/home-ashik-exp-prisma2-react-boilerplate-packages-backend/runtime/index.js:1:86042)
        at processTicksAndRejections (internal/process/task_queues.js:97:5)
    can anyone tell, why I am getting the above error in prisma studio? when order is created, I saw post is connected, you can see from the output of playground, there is a postId, no doubt post is connected. party postgres
    s
    • 2
    • 20
  • e

    Eddy Nguyen

    06/29/2020, 3:12 PM
    Hello! I’m trying to run migration in an AWS RDS instance that’s inside a VPC with prisma2. Here’s what I’ve tried: I have set my current
    PRISMA_DATABASE_URL
    to be
    <mysql://root>:<mailto:password@database.zone.rds.amazonaws.com|password@database.zone.rds.amazonaws.com>:3306/databasename
    Then I run
    prisma generate up --experimental
    . And then I got:
    Copy code
    Error: P1001: Can't reach database server at `<mysql://root:password@database.zone.rds.amazonaws.com:3306/databasename`:`3306>` 
    
    Please make sure your database server is running at `<mysql://root:password@database.zone.rds.amazonaws.com:3306/databasename`:`3306>`.
    Which I think is expected… I don’t think I’m supposed to be able to run arbitrary things against my db from anywhere. FWIW, I have a EC2 instance where I can use to SSH into the database so I know it’s there. I’ve seen others making the RDS publicly accessible but I’m not sure if that’s secured enough? Has anyone able to run migrations for RDS inside VPCs ? What if I want to do this from Github Actions CI/CD? Any help is appreciated 🙏
  • s

    Steve Jenkins

    06/29/2020, 7:59 PM
    Hi all - I'm gearing up to add geolocation search to my graphQL database. Does anyone have suggestions on best 3rd party services or am I missing some built in features for graphQL and geolocation?
    r
    • 2
    • 24
  • f

    fenospro

    06/29/2020, 8:39 PM
    Hello there!! Prisma 2 doesn't support ordering by multiple columns? O.o
  • f

    fenospro

    06/29/2020, 8:44 PM
    I was trying to do this super simple query:
    Copy code
    this.prisma.objective.findMany({
      orderBy: {
        createdByMemberId: 'asc',
        createdAt: 'desc',
      }
    });
    Getting an error:
    Copy code
    ObjectiveOrderByInput needs exactly one argument, but you provided createdByMemberId and createdAt. Please choose one.
    I've literally built 50% of my APP using prisma2 (mostly mutations so far) and now I find out I cannot query and sort by multiple columns. That is very much deal-breaker and heart-breaker for me. There is no mentioning anywhere about this limitation so I'm thinking maybe i need to enable something in order to make this to work? Please help
    👍🏽 1
    r
    • 2
    • 1
  • p

    Philipp Rajah Moura Srivastava

    06/29/2020, 10:34 PM
    Hey all, so I’m trying to get prisma 1 working with subscriptions. I followed the example and it looks like this.
    Copy code
    const userUpdates = {
      subscribe: async (parent, { id }, context, info) => {
        // Function: userUpdates, a resolver function that subscribes to
        // any changes made to a user.
        //
        // Parameter(s):
        //
        //   parent, args, context, info - default prisma parameters
        //   args is an object containing the user Id
        //
        // Return Value(s):
        //
        //   a subscription
         // node: { id_contains: id },
    
        return context.prisma.$subscribe.user({ node: { id: id }, mutation_in: ["UPDATED"] }).node();
      },
      resolve: (payload) => {
        //returning payload
        console.log("hi", "two")
        return payload;
      }
    }
    [8:59 PM] However I’m getting this error when I update a user (edited) 
    Copy code
    [8:59 PM] {
      "errors": [
        {
          "message": "Cannot read property 'get' of undefined",
          "locations": [
            {
              "line": 2,
              "column": 3
            }
          ],
          "path": [
            "userUpdates"
          ]
        }
      ],
      "data": null
    }
    [9:00 PM] I’m using prisma-client-library 1.34.10 [9:01 PM] I’m aware you can use PubSub from graphql-yoga to implement subscriptions so should I go that route or does anyone know a fix to this?
    s
    • 2
    • 1
  • m

    Marco Tedone

    06/29/2020, 10:59 PM
    Hi, I'm trying to get graphql-cli to read my datamodel but without success. Below is my Node project structure. I've called the graphql-cli file .graphql.config.yml. My Types are defined in <rootFolder>/prisma/datamodel.graphql. When I execute the command graphql get-schema nothing happens. The content of the graphql.config.yml file is as follows:
    projects:
    prisma:
    schema: '/src/generated/prisma.graphql'
    And my datamodel is as follows:
    type User {
    id: ID! @id
    name: String!
    email: String! @unique
    posts: [Post!]! @relation(link: INLINE)
    comments: [Comment!]! @relation(link: INLINE)
    createdAt: DateTime! @createdAt
    updatedAt: DateTime! @updatedAt
    }
    type Post {
    id: ID! @id
    title: String!
    body: String!
    published: Boolean!
    author: User!
    comments: [Comment!]! @relation(link: INLINE)
    createdAt: DateTime! @createdAt
    updatedAt: DateTime! @updatedAt
    }
    type Comment {
    id: ID! @id
    text: String!
    author: User!
    post: Post!
    }
    Using Docker Compose everyting works fine, the UI at localhost:4466 shows me all the mutations, queries and subscriptions. But I'd like graphql to generate the prisma.graphql which I can pass to the Prisma object in Node here under the /generated folder.:
    import { Prisma } from 'prisma-binding';
    const prisma = new Prisma({
    typeDefs: './generated/prisma.graphql',
    endpoint: 'localhost:4466',
    });
    Any idea as to why it's not working?
    p
    • 2
    • 48
  • p

    Philipp Rajah Moura Srivastava

    06/30/2020, 1:31 AM
    Can someone let me know what I am doing wrong. I am trying to subscribe to updates on a specific user like so.
    return prisma.$subscribe.user({ where: { mutation_in: ["UPDATED"], node: { id: id } } }).node();
    however, nothing happens when I update the user. If I remove the
    node: { id: id }
    part it works, but also gets updates of other users. Can someone give me some tips?
    r
    • 2
    • 2
  • a

    Ashiqur Rahman

    06/30/2020, 12:45 PM
    Copy code
    const [updatedUser] = await prisma.charge.updateMany({
              where: { stripeId: chargeId },
              data: { refunded: true },
            });
    whats wrong with this array destructuring? isn't is supposed to return an array? but, I am getting the following error:
    Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method
    r
    • 2
    • 1
  • m

    Matheus Assis

    06/30/2020, 1:20 PM
    After updating Prisma from
    2.0.0-beta.6
    to
    2.1.3
    my "skip" properties are gone and this broke some of our queries. Is there a way of having it back? I'm using a calculation of the current page + the amount of items in the page to find the correct amount to skip, without the need of waiting for a network request to do something like, get the id and filter only the ones after it etc. (I'm using @nexus/schema and nexus-prisma but those were unchanged)
    r
    • 2
    • 9
  • a

    Anne Chen

    06/30/2020, 5:37 PM
    Hi everyone, I am getting this error when deploying prisma.
    r
    • 2
    • 2
  • i

    Ivor

    07/01/2020, 10:42 AM
    I'm unable to create a migration with the latest prisma-cli. Am I missing anything?
    npx prisma migrate save --name "add posts" --experimental
    Copy code
    » migrate save is not a prisma command
    Copy code
    // schema.prisma
    model User {
      id        Int      @id @default(autoincrement())
      createdAt DateTime @default(now())
      email     String   @unique
      name      String?
      role      Role     @default(USER)
      posts     Post[]
    }
    
    model Post {
      id Int @id @default(autoincrement())
      createdAt DateTime @default(now())
      updatedAt DateTime @default(now())
      title String?
      body String?
      author User? @relation(fields: [authorId], references: [id])
      authorId Int?
    }
    
    enum Role {
      USER
      ADMIN
    }
    ✔️ 1
    r
    • 2
    • 5
  • a

    Ashiqur Rahman

    07/01/2020, 12:31 PM
    why generated nexus.graphql is different than before, previously I found first, skip, after, before, first etc on that file:
    d
    • 2
    • 1
  • j

    Jane

    07/01/2020, 6:39 PM
    Hello, I am trying to do a PUT request with an upsert and am getting the following error
    Argument id: Got invalid value NaN on prisma.upsertOneUsers. Provided Float, expected Int.
    How do I get it to automatically generate an id if id does not exist?
    Copy code
    put: async (req, res) => {
        try {
          const { id, email, first_name, last_name } = req.body
          const result = await prisma.users.upsert({
            where: { id: Number(id) },
            update: {
              email: email,
              first_name: first_name,
              last_name: last_name
            },
            create: {
              email: email,
              first_name: first_name,
              last_name: last_name
            }
          })
          res.json(result)
        } catch (e) {
          console.warn(e)
          return res.status(400).send('Failed to post Users')
        }
      }
    r
    • 2
    • 1
  • m

    Matheus Assis

    07/02/2020, 5:41 PM
    Are the queries logged with
    log: ['query']
    only the queries that are sent to the db, or ALL queries, including the ones that would be cached locally from the data loader? Is there a way to only log queries that are explicitly sent to the db and not the ones that are cached?
    r
    j
    • 3
    • 4
  • b

    bob

    07/03/2020, 12:33 AM
    does anyone know how to get a single record from a list with prisma 1?
  • b

    bob

    07/03/2020, 12:33 AM
    Copy code
    context.prisma.user({id: "ckbq161w6i1ka0a42wsbtda38" }).packingLists({where: {some id from a relation}  })
    s
    • 2
    • 1
  • b

    bob

    07/03/2020, 12:33 AM
    kinda like that
  • a

    Andre Gustavo

    07/03/2020, 5:04 AM
    Hello, please help me to fix this!!! I'm trying to Prisma and NestJs, when I run "npm run start:dev " I got this:
    Copy code
    src/user/user.resolver.ts:11:5 - error TS2322: Type 'import("/NestJS/librarydash-prisma/node_modules/.prisma/client/index").User[]' is not assignable to type 'import("/NestJS/librarydash-prisma/src/models/user.model").User[]'.
      Type 'User' is missing the following properties from type 'User': createdAt, updatedAt, books
    
    11     return await this.prisma.user.findMany();
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    [01:51:27] Found 1 error. Watching for file changes.
    schema.prisma
    Copy code
    // This is your Prisma schema file,
    // learn more about it in the docs: <https://pris.ly/d/prisma-schema>
    
    datasource db {
      provider = "postgresql"
      url      = env("DATABASE_URL")
    }
    
    generator client {
      provider = "prisma-client-js"
    }
    
    model User {
      id          Int @id @default(autoincrement())
      createdAt   DateTime @default(now())
      updatedAt   DateTime @updatedAt
      role        RoleUser @default(DEFAULT)
      firstName   String
      lastName    String?
      email       String @unique
      password    String
      books       Book[]
    }
    
    model Book {
      id                  Int @id @default(autoincrement())
      createdAt           DateTime @default(now())
      updatedAt           DateTime @updatedAt
      title               String @unique
      author              String[]
      publishedYear       Int
      publishingCompany   String
      copies              Int
      availability        Boolean
      status              String
      coverImage          String[]
      categories          Category[] @relation(references: [id])
      createdBy           User @relation(fields: [userId], references: [id])
      userId              Int
    }
    
    model Category {
      id      Int @id @default(autoincrement())
      name    String
      books   Book[]  @relation(references: [id])
    }
    
    enum RoleUser {
      ADMIN
      DEFAULT
      MANAGER
    }
    user.model.ts
    Copy code
    import { ObjectType, Field, Int, HideField } from '@nestjs/graphql';
    import { Book } from './book.model';
    import { RoleUser } from './../types';
    
    @ObjectType('User')
    export class User {
      @Field(type => Int)
      id: number;
    
      @Field(type => Date)
      createdAt: Date;
    
      @Field(type => Date)
      updatedAt: Date;
    
      @Field(type => RoleUser)
      role: RoleUser;
    
      @Field(type => String)
      firstName: string;
    
      @Field(type => String)
      lastName?: string;
    
      @Field(type => String)
      email: string;
    
      @HideField()
      password: string;
    
      @Field(type => [Book])
      books: Book[];
    }
    book.model.ts
    Copy code
    import { ObjectType, Field, Int } from '@nestjs/graphql';
    import { Category } from './category.model';
    import { User } from './user.model';
    
    @ObjectType()
    export class Book {
      @Field(type => Int)
      id: number;
    
      @Field(type => Date)
      createdAt: string;
    
      @Field(type => Date)
      updatedAt: string;
    
      @Field()
      title: string;
    
      @Field(type => [String])
      author: string[];
    
      @Field()
      publishedYear: number;
    
      @Field()
      publishingCompany: string;
    
      @Field()
      copies: number;
    
      @Field()
      availability: boolean;
    
      @Field()
      status: string;
    
      @Field(type => [String])
      coverImage: string[];
    
      @Field(type => [Category])
      categories: Category;
    
      @Field(type => User)
      createdBy: User;
    }
    category.model.ts
    Copy code
    import { ObjectType, Field, Int } from '@nestjs/graphql';
    import { Book } from './book.model';
    
    @ObjectType()
    export class Category {
      @Field(type => Int)
      id: number;
    
      @Field()
      name: string;
    
      @Field(type => [Book])
      books: Book[];
    }
    user.resolver.ts
    Copy code
    import { Resolver, Query, ResolveField, Parent } from '@nestjs/graphql';
    import { PrismaService } from './../prisma/prisma.service';
    import { User } from './../models';
    
    @Resolver(of => User)
    export class UserResolver {
      constructor(private prisma: PrismaService) {}
    
      @Query(returns => [User])
      async users(): Promise<User[]> {
        return await this.prisma.user.findMany();
      }
    }
    How to fix it???? Thank you!!!!
    r
    • 2
    • 2
  • a

    Ashiqur Rahman

    07/04/2020, 3:53 AM
    can anyone help? I faced some problems when designing the schema. case 1:
    Copy code
    model User {
      package: @relation(fields: [authorId], references: [id])
      packageId: Int
    }
    
    model Package {
      user User[]
    }
    one package can be subscribed by hundreds of users. So, I think this is the way to go. But, the problem is, when a package needs to be deleted, the user(admin) is also needed to be deleted. which we don't want case 2:
    Copy code
    model User {
      package Package[]
    }
    
    model package {
      author      User?  @relation(fields: [authorId], references: [id])
      authorId    Int?
    }
    by designing this way, when the package is deleted, the user is not deleted. but I can't connect multiple users to a package.
    m
    • 2
    • 3
1...384385386...637Latest