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

    ahebwa49

    04/02/2019, 8:51 PM
    Hi guys, I really need some help. How do i write a query resolver with prisma client for a connection in the schema? for example here is my schema.
  • a

    ahebwa49

    04/02/2019, 8:52 PM
    Copy code
    # import * from './generated/prisma-client/prisma.graphql'
    type Query {
      users: [User!]!
      items: [Item!]!
      item(id:ID!):Item
      itemsConnection(where: ItemWhereInput): ItemConnection!
    }
  • a

    ahebwa49

    04/02/2019, 8:52 PM
    below is my guess for the itemsConnection resolver but i don't seem to be lucky at it.
  • a

    ahebwa49

    04/02/2019, 8:54 PM
    Copy code
    const Query = {
      async users(root, args, context, info) {
        const users = await context.prisma.users();
        return users;
      },
      async items(root, args, context, info) {
        const items = await context.prisma.items();
        return items;
      },
      item(root, args, context, info) {
        return context.prisma.item({ id: args.id });
      },
      itemsConnection(root, args, context, info){
        return context.prisma.itemsConnection();
      }
    };
    
    module.exports = Query;
    h
    • 2
    • 1
  • a

    ahebwa49

    04/02/2019, 8:55 PM
    somebody kindly help me out. I need to do some pagination for the items in my db
    o
    • 2
    • 1
  • d

    Daniel Mahon

    04/02/2019, 10:52 PM
    Cant seem to get “subscriptions” to work with prisma lately, nothing is firing unless I manually trigger a `pubsub.publish()`… thoughts? The client seems to be setup ok as I can get the manual publishes.
    Copy code
    const Subscription = {
      // NOTHING FIRES OR UPDATES
      cart: {
        subscribe: async (parent, args, { db }) => {
          return await db.$subscribe
            .cart({ mutation_in: ['CREATED', 'UPDATED'] })
            .node();
        },
        resolve: payload => {
          console.log('payload', payload);
          return payload;
        },
      },
      // WORKS
      counter: {
        subscribe: (parent, args, { pubsub }) => {
          const channel = Math.random()
            .toString(36)
            .substring(2, 15); // random channel name
          let count = 0;
          setInterval(() => pubsub.publish(channel, { counter: count++ }), 2000);
          return pubsub.asyncIterator(channel);
        },
      },
      // WORKS IF I PUBLISH TO CHANNEL THE SAME PLACE IM UPDATING IN RESOLVER
      // cart: {
      //   subscribe: (parent, args, { pubsub }) => {
      //     const channel = 'default';
      //     return pubsub.asyncIterator(channel);
      //   },
      // },
    };
    
    export { Subscription };
  • d

    Daniel Mahon

    04/02/2019, 11:33 PM
    subscribing/updating within playground also does not show updates
    h
    d
    • 3
    • 5
  • p

    Patrick Bassut

    04/03/2019, 1:49 AM
    Hello! Sorry to ask a question right away. I searched and I couldn't find it anywhere. How to have a reverse relation? I have a type A that has a one-to-many relation to B, but B doesn't have any reference to A. I noticed I could just add the reference to A but it complains about me already having nodes so I can't make the field required. This is the message: OrderItem ✖️ You are making a field required, but there are already nodes that would violate that constraint. OrderItem being B in the example
    o
    • 2
    • 4
  • p

    Patrick Bassut

    04/03/2019, 1:49 AM
    --force
    doesn't work
  • j

    Jonathan

    04/03/2019, 5:16 AM
    Hey folks, I’ve searched around and couldn’t find an answer for what I think is a simple issue. I’ve a type with a non-nullable Int field, it’ll either be a 0, 1, 2, or 3. I can write a 1 or a 2 or a 3 as the, but I can’t write a 0. Tried setting the default value to 0 as well, and it the field is created with no value. Am I missing something simple with the Int type?
    h
    • 2
    • 3
  • j

    Jeevadhasan

    04/03/2019, 5:25 AM
    hai guys
    👋 1
  • t

    Tony

    04/03/2019, 6:33 AM
    Hi guys, I've a weird issue I cant seems to get past. When I run 'prisma deploy' on my server with localhost as endpoint, everything seems to work. When I change it to the actual server IP and run the command (ofcourse after respawning new docker containers for prisma), i'm getting stuck on a Auth error. Image attached. How do I solve it ?
    d
    • 2
    • 1
  • t

    Tony

    04/03/2019, 6:35 AM
    @nikolasburk @Prisma Community
  • t

    Tony

    04/03/2019, 6:37 AM
    @divyendu @do4gr
  • j

    Jonathan Goldfarb

    04/03/2019, 9:37 AM
    Hi. I am running prisma with a postgres DB. Every time I run a mutation that violates a DB constraint, the error I get is something like
    Looks like an internal server error....
    and only in the logs of prisma I can see the actual error. Is there any way to make prisma return the actual error?
    h
    • 2
    • 1
  • a

    ArthurBK

    04/03/2019, 11:01 AM
    Hi there, I'm struggling to find a way to filter a subscription, does anyone have some docs about it?
  • a

    ArthurBK

    04/03/2019, 11:01 AM
    Copy code
    context.prisma.$subscribe
      .post({where: { mutation_in: ['CREATED'], node: {
        user: { 
          connect: {
            id: args.userId 
          }
        }
      }
      }}).node()
    h
    • 2
    • 31
  • a

    ArthurBK

    04/03/2019, 11:02 AM
    for instance I would like to subscribe to a new post created by a specific user
  • a

    ArthurBK

    04/03/2019, 11:02 AM
    but this does not trigger any event
  • a

    ArthurBK

    04/03/2019, 11:02 AM
    If anyone has gone through the same problem, any help is welcome 🙂
    d
    • 2
    • 1
  • a

    Anthony

    04/03/2019, 4:05 PM
    I made a Prisma service using the Prisma setup and Heroku. Does the Prisma service keep itself up to date or does that happen automatically when you deploy?
    h
    c
    • 3
    • 6
  • a

    Abhi Aiyer

    04/03/2019, 6:47 PM
    Has anyone run into this issue importing data into prisma
  • a

    Abhi Aiyer

    04/03/2019, 6:47 PM
    field type UUID has no validator defined
  • a

    Abhi Aiyer

    04/03/2019, 6:47 PM
    prisma import runs validation, but im not sure what to do here
    h
    • 2
    • 1
  • e

    eick

    04/04/2019, 8:34 AM
    hi,guys,I want to build a blog, how to choose yoga or apollo server?
    s
    h
    • 3
    • 3
  • c

    Chun

    04/04/2019, 9:08 AM
    Hi, I'm setting up microservice using Prisma on AWS ECS and RDS. However, to save some cost, I would like all services to connect to the single AWS RDS instance. I started with two services. The first service can be started successfully. However, in the second service, the prisma cannot be started. The logs said "Connection times out" as attached. Does Prisma support connection from different Prisma servers to a single database?
    🤔 1
    👀 1
    c
    b
    h
    • 4
    • 6
  • s

    Sébastien

    04/04/2019, 9:23 AM
    Hi there 👋, I'm struggling to add API operations using nexus-prisma. Let's say I have this datamodel:
    Copy code
    type User {
      id: ID! @unique
      password: String!
      name: String
      options: UserOption!
      roles: [Role!]!
    }
    
    type UserOption {
      autosave: Boolean! @default(value: false)
      # more fields ...
    }
    
    enum Role {
      USER
      ADMIN
    }
    How can I add the args
    roles
    and
    options
    in my Mutation objectType ?
    Copy code
    export const Mutation = prismaObjectType({
      name: 'Mutation',
      definition: t => {
        t.field('signup', {
          type: 'AuthPayload',
          args: {
            name: stringArg(),
            password: stringArg(),
            // How to add roles arg (list) here ?
            //? roles
            // How to add options (UserOption) arg ?
            //? options
          },
          resolve: // ...
        });
      }
    });
    🤔
    m
    • 2
    • 5
  • m

    Mathias Kandelborg

    04/04/2019, 10:03 AM
    There's an arg() function you can use. In that you define the type for the arg. @Sébastien
  • s

    siyfion

    04/04/2019, 3:16 PM
    Ahhh I’ve just upgraded my ECS task from 1.22.0 to 1.30.0 and now my entire cluster of instances are throwing errors all over the place! 🤯
  • n

    Nick Drane

    04/04/2019, 3:25 PM
    Hey there, I've got a question regarding
    prisma-nexus
    (which is completely awesome btw) I'm defining a query, and I want an argument to that query to be the same shape as one of my prisma generated graphql input types called
    FundWhereInput
    Copy code
    js
    const Query = prismaObjectType({
      definition: t => {
        t.prismaFields(["*"]);
        t.field("fundStatistics", {
          type: FundStatistics,
          args: { where: /* what goes here */ },
          resolve: async (
            _,
            { where }: { where: FundWhereInput }, // FundWhereInput is imported from `prisma-client/index.ts`
    I'm able to find the TS interface that describes
    FundWhereInput
    , but I also need some graphql representation of this type that I can pass to
    args
    . I assume that I need to pass in some sort of graphql AST version of this type, but the only prisma generated graphql files I can find are either in SDL form or a ts file containing the graphql schema exported as a string. There is also a
    datamodel-info
    file, but I wasn't sure it would be helpful. Where is the thing I need located? Thank you for the help!
    • 1
    • 1
1...246247248...637Latest