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

    Adam Payne

    12/28/2019, 2:04 AM
    Hello 👋 I am having trouble with my mutations. Throwing error context.prisma.create is not a function. I have read in multiple places that i need to deploy and generate but I have done so multiple times. If anyone is available to look at my code please let me know. Thanks 🙏 😁
    b
    • 2
    • 29
  • s

    Simon Gribert

    12/29/2019, 1:32 AM
    Yo! I'm trying to create a query field. I'm thinking it's gonna work something like this: I wanna get all posts between two dates. ie -> Where dates <= x AND dates >= y Now I'm using nexus-prisma and will provide what i have so far in my node file. 🙂
    • 1
    • 2
  • s

    Saidy Barry

    12/30/2019, 5:28 PM
    hello guys how can i use environment variables in prisma2
    j
    • 2
    • 1
  • m

    Mike SOK

    12/30/2019, 11:38 PM
    Hi Guys, I have been struggling with creating a nested mutations (one to many relationship) I keep getting this error message: You provided an invalid argument for the where selector on Item. Please provide exactly one unique field and value. I am trying to connect each created ratings to a single item Id. This is so that I can render the an array of rating on each item. I hope I am making sense. Please if you can give me a hand it would be much appreciated I have been trying to figure this out for a long time. Here is my mutation resolver:
    Copy code
    async createRating(parent, args, ctx, info) {
    
    		const rating = await ctx.db.mutation.createRating({
    
    			data: {
    				// This is how we create a relationship between the Item and the User
    
    				user: {
    					connect: {
    						id: ctx.request.userId
    					}
    				},
    
    				item: {
    					connect: {
    						id: args.itemId
    					},
    				},
    
    				...args
    			},
    		}, 
    
    		info);
    		return rating;
    	},
    Here is my query:
    Copy code
    ratings: forwardTo('db'),
    rating: forwardTo('db'),
    ratingsConnection: forwardTo('db'),
    Here is my schema.graphql:
    Copy code
    # import * from './generated/prisma.graphql'
    type SuccessMessage {
    	message: String
    }
    
    type Mutation {
    	createItem(title: String, description: String, price: Int, image: String, largeImage: String, author: String): Item!
    	updateItem(id: ID!, title: String, description: String, price: Int, author: String): Item!
    	deleteItem(id: ID!): Item
    
    	signup(email: String!, password: String!, name: String!, addressLine1: String!, addressLine2: String, town: String!, county: String!, postCode: String!): User!
    	signin(email: String!, password: String!): User!
    	signout: SuccessMessage
    	requestReset(email: String!): SuccessMessage
    	resetPassword(resetToken: String!, password: String! confirmPassword: String!): User!
    
    	updatePermissions(permissions: [Permission], userId: ID!): User
    
    	addToCart(id: ID!): CartItem
    	removeFromCart(id: ID!): CartItem 
    	createOrder(token: String!): Order!
    
    	contactRequest(firstName: String, lastName: String, email: String!, subject: String!): Contact!
    
    	createRating(ratingSubject: String, ratingImage: String, ratingDescription: String, ratingStar: Int): Rating!
    	updateRating(id: ID!, ratingSubject: String, ratingImage: String, ratingDescription: String, ratingStar: Int): Rating!
    	deleteRating(id: ID!): Rating
    
    }
    
    type Query {
    	items(where: ItemWhereInput, orderBy: ItemOrderByInput, skip: Int, first: Int): [Item]!
    	item(where: ItemWhereUniqueInput!): Item!
    	itemsConnection(where: ItemWhereInput): ItemConnection!
    
      	ratings(where: RatingWhereInput, orderBy: RatingOrderByInput, skip: Int, first: Int): [Rating]!
      	rating(where: RatingWhereUniqueInput!): Rating!
      	ratingsConnection(where: RatingWhereInput): RatingConnection!
    
    	contacts(where: ContactWhereInput, orderBy: ContactOrderByInput, skip: Int, first: Int): [Contact]!
    	contact(where: ContactWhereUniqueInput!): Contact!
    	contactsConnection(where: ContactWhereInput): ContactConnection!
    
    	me: User
    	users: [User]!
    	order(id: ID!): Order
    	orders(orderBy: OrderOrderByInput): [Order]!
    }
    
    type User {
      id: ID!
      name: String!
      email: String!
      addressLine1: String!
      addressLine2: String
      town: String!
      county: String!
      postCode: String!
      permissions: [Permission!]!
      cart: [CartItem!]!
    }
    
    type Item {
    	id: ID!
    	title: String!
    	description: String!
    	image: String
    	largeImage: String
    	price: Int!
    	author: String
    	user: User!
    }
    
    type Rating {
    	id: ID!
    	ratingSubject: String!
    	ratingImage: String
    	ratingDescription: String!
    	ratingStar: Int
    	user: User!
    	item: Item!
    }
    
    type Contact {
    	id: ID!
    	firstName: String!
    	lastName: String!
    	orderId: String!
    	user: User
    	email: String!
    	subject: String!
    	message: String!
    }
    And here is my front end mutation
  • m

    Mike SOK

    12/30/2019, 11:38 PM
    Copy code
    const CREATE_RATING_MUTATION = gql`
    	mutation CREATE_RATING_MUTATION (
    		$ratingSubject: String!
    		$ratingDescription: String!
    		$ratingImage: String
    		$ratingStar: Int!
    		$itemId: ID
    		
    	) {
    		createRating(
    			ratingSubject: $ratingSubject
    			ratingDescription: $ratingDescription
    			ratingImage: $ratingImage
    			ratingStar: $ratingStar
    			item: $itemId
    		) {
    			id
    			item {
    				id
    			}
    		}
    	}
    `;
  • e

    Ethan Glover

    01/01/2020, 12:30 AM
    I'm having a tough time getting Prisma setup with a local Docker container. I can run queries fine on the default port 4466, but I
  • e

    Ethan Glover

    01/01/2020, 12:31 AM
    'm having trouble getting it to run on a port with custom mutationas/queries. So it must be a set up problem? (Screenshots and github link below.)
  • e

    Ethan Glover

    01/01/2020, 12:31 AM
    https://github.com/eglove/CharityApp
    • 1
    • 1
  • g

    Gilbert

    01/01/2020, 6:18 PM
    Hello, How can one pass variables to more than one mutation in React. Below is my mutation. I want to pass data as variable from the Mutation Component.
    Copy code
    export const CREATE_USER_AND_PROFILE = gql`
        mutation createUser($data: CreateUserInput!) {
            createUser(data:$data ) {
            email
            id
            password
            }
        }
        createProfile(data:$data ) {
            fullname
            phone
            address {
                apt
            }
        }
    `;
    l
    • 2
    • 1
  • t

    Tjeerd Ritsma

    01/02/2020, 1:30 PM
    Anyone know about the plans for Go Lang in combination with prisma 2? all I could find was people asking the same question without answer.
    r
    l
    g
    • 4
    • 15
  • l

    Lars Ivar Igesund

    01/03/2020, 11:48 AM
    I want to use accounts.js and the graphql functionality with prisma 1 and nexus-prisma. The main issue is that accounts defines a directive @auth, but if use this in my datamodel, nexus-prisma removes it (at least from the generated .graphql, but I think also from the executable schema). If I understand this correctly, there is no need for nexus-prisma to handle this, the directive only needs to be passed on to the graphql server in the schema. The directive itself can be passed to the server as an additional parameter. Do anyone know nexus-prisma enough to say if this is already possible, or where I should go if I want to do something about it in a patch?
  • a

    Alex

    01/03/2020, 11:48 AM
    Hello, I have a mongodb collection which consists of
    Copy code
    id: ID
    sizes: [
      [Float, Float]
    ]
    How can I describe it in the datamodel.prisma (I mean an array of typles)? Obvious approaches throw me generic errors.
    l
    • 2
    • 6
  • m

    Miroslav Volovec

    01/03/2020, 3:17 PM
    Hi Everyone ... I need some help with creating custom binding table with custom data. Scenario: I have a system, where user can have global role and role related to the project. How to accomplish it?
  • s

    Sergei Ovchinnikov

    01/03/2020, 3:26 PM
    Hello there. I have a question about nexus-prisma plugin with prisma2 setup. Where can i find info on how to hide t.model fields for everyone except the owner?
    export const User = objectType({
    name: 'User',
    definition (t) {
    t.model.id()
    t.model.name()
    t.model.email() // <= I want to show this data only to the user it belongs to
    }
    })
    g
    • 2
    • 2
  • j

    James Fox

    01/03/2020, 4:44 PM
    Hi everyone! Whats the best current suggestion for getting Prisma up and running on AWS Fargate (using AWS RDS Postgres)?
    • 1
    • 1
  • b

    Bryan

    01/03/2020, 7:15 PM
    Hi everyone, I’m looking to create a new project using Prisma and I wonder if we could find something similar to [Sequalize Hooks](https://sequelize.org/master/manual/hooks.html) in that. Thanks in advance.
  • b

    Bryan

    01/04/2020, 5:01 AM
    I have couple of additional questions, there is Nexus with prisma ready to be used in production? and is Nexus interoperable with other ORMs like Typegraphql with others ORMs kinda sequalize?
  • m

    Michael Avnyin

    01/04/2020, 3:13 PM
    Hi all, learning about Prisma and loving it ! 🥰
    prisma rainbow 1
  • a

    aeblin

    01/05/2020, 10:39 AM
    Hey all, having trouble sorting out what the best solution for auth/user management is for Prisma at this point? Is Prisma usable with a third-party user management system a’la Auth0 or Firebase, or is it more or less required that you roll your own now?
    l
    • 2
    • 4
  • d

    Daniel Netzer

    01/05/2020, 2:58 PM
    Hello all, trying to introspect an SQLServer DB, getting
    'ECONNRESET': read ECONNRESET
  • d

    Daniel Netzer

    01/05/2020, 2:58 PM
    anyone have any idea why something like that might happen?
  • v

    vindev

    01/06/2020, 12:21 PM
    Hey guys, can I write something like this:
    Copy code
    type User {
     primaryStory: Story! @relation(name: "userStory")
     secondaryStories: [Story] @relation(name: "userStory")
    }
    
    type Story {
     user: User! @relation(name: "userStory")
    }
    Basically what I want is to have a single relation name for both primary story and secondary stories.
  • g

    Gbolahan Olagunju

    01/06/2020, 4:34 PM
    is there something like https://jsonplaceholder.typicode.com/ (a fake graphQl prisma endpoint) for graphql and prisma that i can use to make tutorials to illustrate a few a few things without having build out my own for each project all the time.
    p
    • 2
    • 2
  • v

    Viktor Szépe

    01/06/2020, 9:52 PM
    Hello! I try hard but unable to prevent prismagraphql/prisma binding to 0.0.0.0
  • v

    Viktor Szépe

    01/06/2020, 9:52 PM
    Copy code
    image: 'prismagraphql/prisma:1.34'
    restart: always
    ports:
      - '127.0.0.1:4466:4466'
    does not help
  • v

    Viktor Szépe

    01/06/2020, 9:53 PM
    How to get prisma not to expose its port to all interfaces?
    d
    • 2
    • 10
  • v

    Victor

    01/06/2020, 10:53 PM
    https://www.codemochi.com/blog/2019-08-12-prisma-2-now
    🚀 3
    ❤️ 1
  • e

    evondev

    01/07/2020, 4:10 AM
    Hello erveryone! When we can use prisma2 for production? currently prisma1 make high cpu usage, is there prisma2 written in Rust will make project faster and make cpu low. thanks
    s
    • 2
    • 1
  • e

    evondev

    01/07/2020, 4:21 AM
    So when prisma2 is in production in mid of this year ? Is that difficulty to change from old project with prisma1 to prisma2 like datamodel, mutation, query...etc
    s
    • 2
    • 1
  • d

    Daniel Netzer

    01/07/2020, 3:43 PM
    Hello all again, I've created a small benchmark comparing sequlize to prisma for a simple query, everything is local, the postgres DB is hosted on the same docker with prisma, and the results are that prisma takes 100 times more to resolve the query
    🙏 1
1...340341342...637Latest