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

    Ecker

    03/16/2019, 9:04 AM
    What is the recommended way to store lots of user meta fields? (All generic small data fields on a user such as: eula, role, newsletter, temp cached data, consent to this/that, turned on setting X and Y, etc). Usually in my old MySQL projects I hate having these as individual columns, as it becomes manageable and keeps on growing, while most of the values/columns are just
    null
    for 90% of users. — So I've usually stored this as a JSON column in MySQL, which did work great back then. But with Prisma, graphql and graphql-bindings I see that this JSON approach would lose a lot of the power of graphql, making me have to do lots of manual validation on this json object. So I'm wondering how to best deal with lots of these meta values in Prisma?
    Copy code
    type User {
      id: ID! @unique
      email: String! @unique
      password: String!
      meta1: Json! # ← My traditional approach, any data, any structure)
      meta2: UserMeta! # ← Thinking this might be better?
    }
    
    type UserMeta {
      role: UserRole!
      newsletter: Boolean
      # …etc, lots of other fields
    }
    
    enum UserRole {
      MEMBER,
      SUPER
    }
    But I still kinda dislike that the
    UserMeta
    might grow to 20+ columns, and most of those columns will be
    null
    or the default value for most users.
    ✔️ 1
    👍 1
    j
    a
    f
    • 4
    • 8
  • m

    Myer Nore

    03/16/2019, 11:51 AM
    I've posted a question about graphql-yoga docs to stack overflow - any input is greatly appreciated! https://stackoverflow.com/questions/55196419/graphql-yoga-where-are-graphql-resolver-arguments-defined-and-documented
  • h

    HoYeon

    03/16/2019, 3:35 PM
    Hello I'm now representing login feature using Prisma but a problem occurs. After I get email and password from args, I use prisma.user({email, password}) to find a user satisfying the requirements. But where type is UserWhereUniqueUniqueInput and its input is only unique! What should I do to solve this problem?
  • r

    Ryan Slama

    03/16/2019, 4:24 PM
    Hey! I'm getting an error when I try to follow the getting started tutorial with my existing Postgres database. (https://www.prisma.io/docs/1.28/get-started/01-setting-up-prisma-existing-database-TYPESCRIPT-t003/) From what I saw online, this was an issue in the past with field names and I do have a "Series" field which might be problematic. Are there any workarounds for this?
  • r

    Ryan Slama

    03/16/2019, 4:24 PM
    -.js
  • j

    jblevins

    03/16/2019, 6:25 PM
    I am trying to write some graphql-yoga middleware to cache the requests and their responses in redis. Is there a way to pull queries and mutations from yoga's request argument?
  • e

    ezeikel

    03/16/2019, 6:53 PM
    Copy code
    // datamodel.prisma
    enum Permission {
      ADMIN
      USER
      PERMISSIONUPDATE
    }
    
    enum Gender {
      MALE
      FEMALE
      NONBINARY
      NOTSPECIFIED
    }
    
    type User {
      id: ID! @id
      name: String
      username: String @unique
      website: String
      bio: String
      email: String! @unique
      phoneNumber: Int
      gender: Gender!
      following: [User!]! @relation(name: "Following", link: INLINE)
      followers: [User!]! @relation(name: "Followers", link: INLINE)
      password: String!
      resetToken: String
      resetTokenExpiry: String
      posts: [Post!]! @relation(name: "Posts", link: INLINE)
      permissions: [Permission!]!
      createdAt: DateTime! @createdAt
      updatedAt: DateTime! @updatedAt
    }
    
    type Post {
      id: ID! @id
      author: User! @relation(name: "Author", link: INLINE)
      image: String
      caption: String
      location: Location
      published: Boolean @default(value: false)
      likes: [User!]! @relation(name: "Likes", link: INLINE)
      comments: [Comment!]!
      createdAt: DateTime! @createdAt
    }
    
    type Location @embedded {
      latitude: Float!
      longitude: Float!
    }
    
    type Comment @embedded {
      text: String!
      writtenBy: User!
      createdAt: DateTime! @createdAt
    }
    h
    • 2
    • 1
  • e

    ezeikel

    03/16/2019, 6:57 PM
    Im getting this error when running
    prisma deploy
    ERROR: There is a relation ambiguity during the migration. Please first name the old relation on your schema. The ambiguity is on a relation between Post and User. Please name relations or change the schema in steps.
    Im not sure why? Also, If anyone can let me know what the
    name
    property does for `@relation`as I cant find it explained in the docs
  • r

    Rodrigo Vieira

    03/16/2019, 10:17 PM
    Hello, everyone! What would be a nice and easy way to configure testing with Jest in a project using GraphQL and Prisma? NodeJS as server.
    w
    • 2
    • 2
  • c

    csamu

    03/16/2019, 11:18 PM
    Does Prisma work with MariaDB? 👶
    w
    b
    h
    • 4
    • 4
  • j

    Jayphen

    03/17/2019, 10:17 AM
    hey guys, I have a wee question I hope someone can point me in the right direction. I am building a graphql backend for the first time. I am wondering how I might implement a 'depth' argument for a self-referential type? e.g. here where
    subPlaces
    is self-referential. I would like to query
    places(depth: Int!)
    so that I can build a tree structure.
    Copy code
    type Place {
      id: ID! @unique
      name: String!
      things: [Thing]! @relation(name: "ThingsInPlace", onDelete: CASCADE)
      subPlaces: [Place]
    }
    • 1
    • 1
  • p

    Pankaja

    03/17/2019, 10:48 AM
    Hi guys, I'm newbie here. Few days ago I started learning GraphQL stack.
  • p

    Pankaja

    03/17/2019, 10:49 AM
    Anyway, I'm creating a basic app to get familiar with GraphQL, Apollo, Prisma stuff. So, I'm using Prisma Demo server with the database. I need to know how can I deploy the changes once I changed my data model in datamodel.prisma file ?
  • p

    Pankaja

    03/17/2019, 10:51 AM
    I tried prisma deploy . It shows the changes are applied. But when I check in my prisma service, the database has not been changed. How can I apply the datamodel.prisma changes to the database as well ?
    n
    • 2
    • 2
  • b

    btotharye

    03/17/2019, 1:46 PM
    Can anyone by chance tell me what I have wrong here on this query, it works until I add in the owner part and I'm sure I don't have the syntax right:
    Copy code
    query Snakes{
      snakes(
        where: {
          OR: [
            {name_contains: "pie"}
            {description_contains: "pie"}
          ]
          AND: [
            {owner: {id: "someuseridhere"}}
          ]
        }
      ) { id name}
    }
    n
    • 2
    • 4
  • a

    antonbramsen

    03/17/2019, 8:42 PM
    Does anyone have any permission examples using the graphql-shield custom errors. I have a hard time understanding how to implement them from the documentation? - I am writing my graphql server using code first approach with nexus-prisma.
    h
    m
    • 3
    • 3
  • m

    medelman

    03/17/2019, 11:55 PM
    Anyone ever run into a situation where
    prisma deploy
    wants to deploy to prisma cloud (despite contents of
    prisma.yml
    ) but every other command, including
    prisma reset
    appears to be working fine?
    m
    d
    h
    • 4
    • 24
  • j

    James

    03/18/2019, 2:07 AM
    Imagine I'm an idiot. I want to get management API secured. I have read in the docs and accordingly set managementApiSecret in docker-compose.yml and after running prisma deploy, nothing is different. What am I missing?
    h
    d
    • 3
    • 4
  • y

    Yohann

    03/18/2019, 6:15 AM
    Any plans to have an official scala client for prisma?
    h
    • 2
    • 1
  • g

    go4cas

    03/18/2019, 6:46 AM
    Hey guys ... I have a question on using Prisma with Postgres schemas ... When starting a new Prisma app, on an existing db, I get presented with a list of the schemas in the db. First question is: Does this mean that I will have to create a separate Prisma app for each schema? Also, I have tables in one schema with foreign keys pointing to a table in another schema. Now, when I try to create a new Prisma app, I get
    Failed to resolve FK constraint
    errors. Any way around this?
    h
    • 2
    • 1
  • s

    Steve Mason

    03/18/2019, 1:26 PM
    Prisma Cloud id field invalid I’m having an issue deploying my datamodel to Prisma Cloud (demo server). My id fields in my datamodel are all set to the type
    id: ID! @id
    . When I try deploying to Prisma Cloud, I get this error:
    Copy code
    User
        ✖ The field `id` is reserved and has to have the format: id: ID! @unique or id: UUID! @unique.
    If I change my datamodel to
    id: ID! @unique
    , it deloys to the cloud, but my local prisma client/db no longer works. I’m using mongodb locally, does this make a difference? Here’s my
    prisma.yml
    Copy code
    endpoint: ${env:PRISMA_CLIENT_ENDPOINT}
    datamodel: server/datamodel.prisma
    databaseType: document
    secret: ${env:PRISMA_SECRET}
    generate:
      - generator: typescript-client
        output: ./generated/prisma-client/
    hooks:
      post-deploy:
        - prisma generate
    I could programmatically include a different root datamodel with just the id types based on an env var, but that’s kinda weak I’d rather not if I don’t have to.
    Copy code
    # prisma.yml
    ...
    datamodel:
      - ${env.PRISMA_ROOT_DATAMODEL}
      - server/datamodel.prisma
    Any ideas?
    h
    • 2
    • 2
  • b

    btotharye

    03/18/2019, 4:41 PM
    stupid question I know the ES connector isn't there yet but if I wanted to use elasticsearch with my data inside my prisma postgres db is there a option for that? Would it work just indexing the db or anyone done this yet?
    h
    • 2
    • 4
  • j

    José Gomes

    03/18/2019, 5:23 PM
    How can i protect my prisma endpoint from this type of attacks?
    h
    u
    • 3
    • 6
  • r

    raul

    03/18/2019, 6:59 PM
    Hi, someone has info about upgrading prisma version in server?
  • r

    raul

    03/18/2019, 7:00 PM
    my current prisma setup is hosted in heroku (prisma cloud)
  • z

    Zyon

    03/18/2019, 7:27 PM
    On prisma server I keep getting this error "Value expected to be of type DOCUMENT is of unexpected type ARRAY"
  • z

    Zyon

    03/18/2019, 7:27 PM
    any idea why?
  • e

    ezeikel

    03/18/2019, 10:57 PM
    Evening all. Wanted to know if there is a way of updating two Users
    follow
    and
    following
    fields in ONE Mutation after one User follows another rather than having to fire off a separate Mutation for each User to update the respective fields like how it is done here https://github.com/prisma/prisma/issues/1609#issuecomment-365266599
    Copy code
    async follow(parent, { username }, ctx, info) {
        const auth0Id = await parseUserAuth0Id(ctx)
        await ctx.db.mutation.updateUser({
          where: { auth0Id },
          data: {
            following: {
              connect: [{ username }]
            }
          }
        })
        return await ctx.db.mutation.updateUser({
          where: { username },
          data: {
            followers: {
              connect: [{ auth0Id }]
            }
          }
        }, info)
      },
    
      async unfollow(parent, { username }, ctx, info) {
        const auth0Id = await parseUserAuth0Id(ctx)
        await ctx.db.mutation.updateUser({
          where: { auth0Id },
          data: {
            following: {
              disconnect: [{ username }]
            }
          }
        })
        return await ctx.db.mutation.updateUser({
          where: { username },
          data: {
            followers: {
              disconnect: [{ auth0Id }]
            }
          }
        }, info)
      },
  • a

    Alex A

    03/19/2019, 12:02 AM
    Hey does anyone know the best way to handle postgres views in prisma?
  • a

    Alex A

    03/19/2019, 12:02 AM
    Didn't see anything in the documentation
1...237238239...637Latest