Rodrigo
06/27/2020, 5:20 PMSameer kashyap
06/28/2020, 9:40 AMprisma
to MongoDB
? or is it not supported yet?Marco Tedone
06/28/2020, 3:43 PMStefan Trivuncic
06/28/2020, 10:47 PMPrisma 2
, how is everyone’s workflow in terms of running a local database locally via PostgreSQL
? Do you still run a docker container?Philipp Rajah Moura Srivastava
06/29/2020, 1:58 AMconst 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;
}
}
Philipp Rajah Moura Srivastava
06/29/2020, 1:59 AMPhilipp Rajah Moura Srivastava
06/29/2020, 1:59 AM{
"errors": [
{
"message": "Cannot read property 'get' of undefined",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"userUpdates"
]
}
],
"data": null
}
Philipp Rajah Moura Srivastava
06/29/2020, 2:00 AMPhilipp Rajah Moura Srivastava
06/29/2020, 2:01 AMChristoph Dietrich
06/29/2020, 11:02 AMAshiqur Rahman
06/29/2020, 12:53 PMError 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 postgresEddy Nguyen
06/29/2020, 3:12 PMPRISMA_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:
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 🙏Steve Jenkins
06/29/2020, 7:59 PMfenospro
06/29/2020, 8:39 PMfenospro
06/29/2020, 8:44 PMthis.prisma.objective.findMany({
orderBy: {
createdByMemberId: 'asc',
createdAt: 'desc',
}
});
Getting an error:
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 helpPhilipp Rajah Moura Srivastava
06/29/2020, 10:34 PMconst 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)
[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?Marco Tedone
06/29/2020, 10:59 PMprojects:
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?Philipp Rajah Moura Srivastava
06/30/2020, 1:31 AMreturn 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?Ashiqur Rahman
06/30/2020, 12:45 PMconst [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
Matheus Assis
06/30/2020, 1:20 PM2.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)Anne Chen
06/30/2020, 5:37 PMIvor
07/01/2020, 10:42 AMnpx prisma migrate save --name "add posts" --experimental
» migrate save is not a prisma command
// 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
}
Ashiqur Rahman
07/01/2020, 12:31 PMJane
07/01/2020, 6:39 PMArgument 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?
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')
}
}
Matheus Assis
07/02/2020, 5:41 PMlog: ['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?bob
07/03/2020, 12:33 AMbob
07/03/2020, 12:33 AMcontext.prisma.user({id: "ckbq161w6i1ka0a42wsbtda38" }).packingLists({where: {some id from a relation} })
bob
07/03/2020, 12:33 AMAndre Gustavo
07/03/2020, 5:04 AMsrc/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
// 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
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
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
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
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!!!!Ashiqur Rahman
07/04/2020, 3:53 AMmodel 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:
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.