Adam Payne
12/28/2019, 2:04 AMSimon Gribert
12/29/2019, 1:32 AMSaidy Barry
12/30/2019, 5:28 PMMike SOK
12/30/2019, 11:38 PMasync 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:
ratings: forwardTo('db'),
rating: forwardTo('db'),
ratingsConnection: forwardTo('db'),
Here is my schema.graphql:
# 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 mutationMike SOK
12/30/2019, 11:38 PMconst 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
}
}
}
`;
Ethan Glover
01/01/2020, 12:30 AMEthan Glover
01/01/2020, 12:31 AMEthan Glover
01/01/2020, 12:31 AMGilbert
01/01/2020, 6:18 PMexport const CREATE_USER_AND_PROFILE = gql`
mutation createUser($data: CreateUserInput!) {
createUser(data:$data ) {
email
id
password
}
}
createProfile(data:$data ) {
fullname
phone
address {
apt
}
}
`;
Tjeerd Ritsma
01/02/2020, 1:30 PMLars Ivar Igesund
01/03/2020, 11:48 AMAlex
01/03/2020, 11:48 AMid: 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.Miroslav Volovec
01/03/2020, 3:17 PMSergei Ovchinnikov
01/03/2020, 3:26 PMexport 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
}
})
James Fox
01/03/2020, 4:44 PMBryan
01/03/2020, 7:15 PMBryan
01/04/2020, 5:01 AMMichael Avnyin
01/04/2020, 3:13 PMaeblin
01/05/2020, 10:39 AMDaniel Netzer
01/05/2020, 2:58 PM'ECONNRESET': read ECONNRESET
Daniel Netzer
01/05/2020, 2:58 PMvindev
01/06/2020, 12:21 PMtype 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.Gbolahan Olagunju
01/06/2020, 4:34 PMViktor Szépe
01/06/2020, 9:52 PMViktor Szépe
01/06/2020, 9:52 PMimage: 'prismagraphql/prisma:1.34'
restart: always
ports:
- '127.0.0.1:4466:4466'
does not helpViktor Szépe
01/06/2020, 9:53 PMVictor
01/06/2020, 10:53 PMevondev
01/07/2020, 4:10 AMevondev
01/07/2020, 4:21 AMDaniel Netzer
01/07/2020, 3:43 PM