Hi again,
I’ve read through this article about the issues with scaffolding in relationships
An opinionated Javascript framework that combines React, GraphQL, Prisma2, SQL, and lots more out of the box.
Is there a “non-scaffold” way to allow this though?
I had hoped that the below would work
export const schema = gql`
type Client {
id: Int!
firstName: String!
lastName: String!
createdAt: DateTime!
clinic: Clinic
clinicId: Int
}
type Query {
clients: [Client!]!
}
input CreateClientInput {
firstName: String!
lastName: String!
clinicId: Int
clinic: Clinic
}
input UpdateClientInput {
firstName: String
lastName: String
clinicId: Int
clinic: Clinic
}
type Mutation {
createClient(input: CreateClientInput!): Client!
updateClient(id: Int!, input: UpdateClientInput!): Client!
deleteClient(id: Int!): Client!
}
`
Tobbe
January 10, 2021, 6:26pm
2
Hi @andregoldstein . What problems do you have with the schema you posted? Any error messages to share? More details would be helpful. Thanks
1 Like
@andregoldstein It’s been a few days so not sure if this is relevant.
The docs you mentioned are a bit behind on latest from Prisma. As of Prisma v2.11 (and Redwood v0.21) you no longer need to go through the whole workaround to handle relations. Not sure if this is a part of the problem you encountered, but do check out the section “Set foreign keys directly (Preview)” from these Prisma release notes:
1 Like
@Tobbe and @thedavid Thanks so much for taking the time to reply. I hadn’t revisited this bit of code so sorry for lack of follow up.
I think I was struggling initially to create the connections via connect and then latterly to query the relationship.
In the end I got it working but perhaps I wasn’t quite sure exactly how I did so.
Perhaps a full working example would be great but I’ll be sure to check out the latest Prisma docs as soon as possible!
Thanks!
1 Like