ahebwa49
02/19/2019, 10:11 AMjoan
02/19/2019, 10:23 AMcomponentA
loads a query like this: <Query query={EVENT_QUERY} variables={{ slug: this.props.match.params.slug }}>
with the following qgl:
export const EVENT_QUERY = gql`
query EventQuery($slug: String!) {
event(slug: $slug) {
id
slug
description
title
dates {
id
timestamp
}
places {
id
name
url
}
participants {
id
name
}
menus
}
}
`;
And then I pass participants
to componentB
What if componentC
makes a create mutation
and adds a new participant
to that event... How should I update the original query so that the changes with cascade down to components A and B?Oskar
02/19/2019, 10:25 AMrein
02/19/2019, 10:26 AMJon
02/19/2019, 12:06 PM[GraphQL error]: Message: You provided an invalid argument for the where selector on User., Location: , Path: updateUser
Uncaught (in promise) Error: GraphQL error: You provided an invalid argument for the where selector on User.
schema.graphql
...
# import * from './generated/prisma-client/prisma.graphql'
updateUser(email: String, firstName: String, lastName: String, password: String): User!
...
Mutation.js
async updateUser(parent, args, ctx, info) {
// First check if there is a user with that email
const user = await ctx.db.query.user({ where: { email: args.email } });
if (user) {
throw new Error(`The email ${args.email} is already being used`);
}
const updatedUser = await ctx.db.mutation.updateUser({
where: { id: args.id },
data: {
email: args.email,
firstName: args.firstName,
lastName: args.lastName
}
});
return updatedUser;
}
Frontend Mutation:
const UPDATE_USER_MUTATION = gql`
mutation UPDATE_USER_MUTATION(
$email: String!
$firstName: String!
$lastName: String!
) {
updateUser(email: $email, firstName: $firstName, lastName: $lastName) {
id
email
firstName
lastName
}
}
`;
What am I doing wrong here?rein
02/19/2019, 12:10 PMrein
02/19/2019, 12:10 PMJidé
02/19/2019, 12:41 PMJidé
02/19/2019, 12:42 PMJoeE
02/19/2019, 1:06 PMMartĂ CrespĂ
02/19/2019, 2:21 PMMartĂ CrespĂ
02/19/2019, 2:21 PMstephan
02/19/2019, 3:29 PMstephan
02/19/2019, 3:30 PMstephan
02/19/2019, 3:30 PMRobert Kaczmarek
02/19/2019, 4:57 PMMike Pechousek
02/19/2019, 5:43 PMMike Pechousek
02/19/2019, 5:44 PMMike Pechousek
02/19/2019, 5:44 PMMike Pechousek
02/19/2019, 5:45 PMMatt Abrams
02/20/2019, 4:10 AMprisma
on context
. It might simply come down to needing to @ts-ignore
every use of a mock prisma seeing as the type definition is pretty huge to replicate an instance of. Thanks!Andrei Bacescu
02/20/2019, 7:44 AM<https://www.prisma.io/tutorials/bootstrap-a-graphql-server-in-typescript-ct09/>
is outdated. This tutorial was supposed to use prisma-binding but instead, it uses prisma-client. Thanks.codebeast
02/20/2019, 8:29 AMcodebeast
02/20/2019, 8:30 AMLineItemCreateManyWithoutInvoiceInput
codebeast
02/20/2019, 8:30 AMschema.graphql
stephan
02/20/2019, 9:07 AMstephan
02/20/2019, 9:07 AMstephan
02/20/2019, 9:07 AMMartĂ CrespĂ
02/20/2019, 9:27 AMbkstorm
02/20/2019, 9:33 AMgenerated
folder. There is no errors when running graphql server, does anyone have this problem and how to fix it. Thanks!
const Query = prismaObjectType({
name: 'Query',
definition: t => t.prismaFields(['*']),
})
const Mutation = prismaObjectType({
name: 'Mutation',
definition: t => t.prismaFields(['*']),
})
const schema = makePrismaSchema({
types: [Query, Mutation],
prisma: {
datamodelInfo: metaSchema,
client: prisma,
},
outputs: {
schema: path.join(__dirname, './generated/schema.graphql'),
typegen: path.join(__dirname, './generated/nexus.ts'),
},
})