<@UCZMXEP3J> Is there a way to get the fully popul...
# orm-help
c
@Harshit Is there a way to get the fully populated object with the child types populated on it so I don’t have to make a series of follow-up calls through
Type Resolvers
to get access to those Types? Example:
Copy code
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?
h
Yes, you can use the fragment syntax for that
c
Is this what you’re referring to? Is it current?
Copy code
prisma.links().$fragment(`
  fragment LinksWithUser on Link {
    id
    createdAt
    description
    url
    postedBy {
      id
      name
    }
  }
`)
h
Yes