Max Tayebwa
11/25/2019, 9:40 AMUmair Khan
11/25/2019, 11:30 AMvjsingh
11/25/2019, 3:40 PMvjsingh
11/25/2019, 3:40 PMdeactivateduser
11/25/2019, 6:13 PMdeactivateduser
11/25/2019, 6:22 PMRaul Saavedra
11/25/2019, 8:45 PMtype User {
id: ID! @id
name: String!
email: String! @unique
password: String!
resetToken: String
resetTokenExpiry: Float
permissions: [Permission] @scalarList(strategy: RELATION)
}
type Item {
id: ID! @id
title: String!
description: String!
image: String
largeImage: String
price: Int!
createdAt: DateTime! @createdAt
updatedAt: DateTime! @updatedAt
user: User!
}
The generated part of Prisma:
type Mutation {
createItem(data: ItemCreateInput!): Item!
}
input ItemCreateInput {
id: ID
title: String!
description: String!
image: String
largeImage: String
price: Int!
user: UserCreateOneInput!
}
input UserCreateOneInput {
create: UserCreateInput
connect: UserWhereUniqueInput
}
input UserWhereUniqueInput {
id: ID
email: String
}
And the resolver:
async createItem(parent, args, ctx, info) {
if (!ctx.request.userId) {
throw new Error('You must be logged in to perform this action');
}
const item = await ctx.db.mutation.createItem(
{
data: {
...args,
user: {
connect: { id: ctx.request.userId }
},
},
},
info
);
return item;
},
However, I am getting an error: Field 'user' is not defined in the input type 'ItemCreateInput'.
I would greatly appreciate your help!Seppe Snoeck
11/25/2019, 8:58 PMtype User {
id: ID! @id
email: String @unique
firstName: String!
lastName: String!
password: String
posts: [Post!]!
}
But I can query a user’s password. How can I prevent this?Seppe Snoeck
11/25/2019, 9:45 PMandrew bantug
11/25/2019, 10:30 PMrequire('dotenv').config()
const { GraphQLServer } = require('graphql-yoga');
const { Mutation, Query } = require('./resolvers')
const { Prisma } = require('prisma-binding')
const prisma = new Prisma({
typeDefs: 'generated/prisma.graphql',
endpoint: process.env.PRISMA_ENDPOINT,
secret: process.env.PRISMA_SECRET
})
const server = new GraphQLServer({
typeDefs: 'src/schema.graphql',
resolvers: { Query, Mutation },
resolverValidationOptions: {
requireResolversForResolveType: false,
},
context: (req) => ({...req, prisma})
});
const options = {
port: process.env.PORT,
playground: process.env.GRAPHQL_PLAYGROUND
}
server.start(
options,
(options) => console.log(`Server Started. Running on port ${options.port}`)
);
Nesh
11/25/2019, 11:09 PMBen
11/26/2019, 7:57 AMBen
11/26/2019, 7:57 AMBen
11/26/2019, 7:58 AMDaniel Boros
11/26/2019, 10:03 AMcsamu
11/26/2019, 11:48 AMRayees
11/26/2019, 12:45 PMCannot read property 'fields' of undefined
after i tried to execute command prisma init hello-world
Rayees
11/26/2019, 12:47 PMJunior Vidotti
11/26/2019, 2:00 PM@unique
directive together with relations is not working on Postgres (didn't tested another database). My model:
type User {
id: ID! @id
name: String! @unique
}
type Profile {
id: ID! @id
user: User! @unique
phone: String
}
Then I tried to create two profile to same user, thus violating @unique rule.
mutation {
operation1: createProfile(data: {
user: {
connect: {
name: "Junior"
}
}
phone: "<tel:5555555555|555 555-5555>"
}) {id user {id name} phone}
operation2: createProfile(data: {
user: {
connect: {
name: "Junior"
}
}
phone: "<tel:6665555555|666 555-5555>"
}) {id user {id name} phone}
}
Prisma allowed:
{
"data": {
"operation1": {
"id": "ck3fxhkdh01zk0707j1rr31ri",
"user": {
"id": "ck3fx7fld01td0707xeenbd97",
"name": "Junior"
},
"phone": "<tel:5555555555|555 555-5555>"
},
"operation2": {
"id": "ck3fxhkds01zp0707ng658rsw",
"user": {
"id": "ck3fx7fld01td0707xeenbd97",
"name": "Junior"
},
"phone": "<tel:6665555555|666 555-5555>"
}
}
}
Junior Vidotti
11/26/2019, 2:03 PMLars Ivar Igesund
11/26/2019, 6:41 PMquery posts($where: PostWhereInput, $orderBy: PostOrderByInput, $skip: Int, $first: Int) {
items: posts(where: $where, orderBy: $orderBy, skip: $skip, first: $first) {
id
title
published
author {
id
__typename
}
__typename
}
total: postsConnection(where: $where) {
aggregate {
count
__typename
}
__typename
}
}
Lars Ivar Igesund
11/26/2019, 6:44 PMtype PostConnection {
pageInfo: PageInfo!
edges: [PostEdge!]!
aggregate: AggregatePost!
}
but the result says:
"errors": [
{
"message": "Unknown prisma-client function for field PostConnection.aggregate",
"locations": [
{
"line": 13,
"column": 5
}
],
"path": [
"total",
"aggregate"
],
Is it the total part that is the problem maybe?Lars Ivar Igesund
11/26/2019, 6:45 PMLars Ivar Igesund
11/26/2019, 6:53 PMSeppe Snoeck
11/26/2019, 7:03 PMjregistr
11/26/2019, 7:36 PMBen
11/27/2019, 9:32 AMBen
11/27/2019, 9:32 AMBurim Ameti
11/27/2019, 11:30 AMMatt Wilson
11/27/2019, 3:33 PM