ahebwa49
04/02/2019, 8:51 PMahebwa49
04/02/2019, 8:52 PM# import * from './generated/prisma-client/prisma.graphql'
type Query {
users: [User!]!
items: [Item!]!
item(id:ID!):Item
itemsConnection(where: ItemWhereInput): ItemConnection!
}
ahebwa49
04/02/2019, 8:52 PMahebwa49
04/02/2019, 8:54 PMconst 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;
ahebwa49
04/02/2019, 8:55 PMDaniel Mahon
04/02/2019, 10:52 PMconst 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 };
Daniel Mahon
04/02/2019, 11:33 PMPatrick Bassut
04/03/2019, 1:49 AMPatrick Bassut
04/03/2019, 1:49 AM--force
doesn't workJonathan
04/03/2019, 5:16 AMJeevadhasan
04/03/2019, 5:25 AMTony
04/03/2019, 6:33 AMTony
04/03/2019, 6:35 AMTony
04/03/2019, 6:37 AMJonathan Goldfarb
04/03/2019, 9:37 AMLooks 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?ArthurBK
04/03/2019, 11:01 AMArthurBK
04/03/2019, 11:01 AMcontext.prisma.$subscribe
.post({where: { mutation_in: ['CREATED'], node: {
user: {
connect: {
id: args.userId
}
}
}
}}).node()
ArthurBK
04/03/2019, 11:02 AMArthurBK
04/03/2019, 11:02 AMArthurBK
04/03/2019, 11:02 AMAnthony
04/03/2019, 4:05 PMAbhi Aiyer
04/03/2019, 6:47 PMAbhi Aiyer
04/03/2019, 6:47 PMfield type UUID has no validator defined
Abhi Aiyer
04/03/2019, 6:47 PMeick
04/04/2019, 8:34 AMChun
04/04/2019, 9:08 AMSébastien
04/04/2019, 9:23 AMtype 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 ?
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: // ...
});
}
});
🤔Mathias Kandelborg
04/04/2019, 10:03 AMsiyfion
04/04/2019, 3:16 PMNick Drane
04/04/2019, 3:25 PMprisma-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
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!