Corey Snyder
08/08/2019, 2:53 PMType Resolvers
to get access to those Types? Example:
type User {
id: ID! @id
name: String!
email: String! @unique
active: Boolean @default(value: false)
updatedBy: User @relation(name: "EditedUser")
updatedAt: DateTime @updatedAt
password: String!
links: [Link!]!
votes: [Vote!]!
flightControllers: [FlightController!]! @relation(name: "AddedFlightControllers")
editedFlightControllers: [FlightController!]! @relation(name: "EditedFlightControllers")
addedMerchants: [Merchant!]! @relation(name: "AddedMerchants")
editedMerchants: [Merchant!]! @relation(name: "EditedMerchants")
AddedFlightControllers: [FlightControllerMerchantLink!]! @relation(name: "AddedFlightControllerMerchantLinks")
role: Role @default(value: USER)
emailVerification: [EmailVerification] @relation(name: "UserEmailVerifications")
}
Now in my code I want to query for a user, and get all of the child types populated in my code. If I simply return the user, I’m able to query the child types just fine via GraphQL queries but if in my code I needed a list of the votes I have to re-run the query:
context.prisma.user({ id: args.user.id }).votes()
and if I wanted the links
context.prisma.user({ id: args.user.id }).links()
Is there a way to get this in 1 go?Harshit
08/08/2019, 2:54 PMCorey Snyder
08/08/2019, 3:05 PMprisma.links().$fragment(`
fragment LinksWithUser on Link {
id
createdAt
description
url
postedBy {
id
name
}
}
`)
Harshit
08/08/2019, 3:07 PM