Hey all, not sure if this is the place to post thi...
# orm-help
t
Hey all, not sure if this is the place to post this, as it's about the nexus-prisma plugin, but I'm having trouble getting the
root
object passed into my Nexus resolvers to contain my relation fields from Prisma. ie, imagine this as a resolver for
tableA
Copy code
t.field('tableBFoo', {
      type: 'DateTime',
      async resolve(root, _args, { prisma }) {
        const valueB = prisma.tableB.findUnique({
          select: {
            foo: true,
      },
      where: {
        objectId: root.tableB.objectId,
      },
    })
    return valueB.foo
  },
})
root.tableA
comes up null in this example. Not sure if this translates exactly, haven't tried it out, but the model for the above, if done the same way that we have it, should look like this:
Copy code
model TableA {
  objectId    String @id
  tableBId    String @map("tableB")
  tableB      TableB? @relation(fields: [tableBId], references: [objectId])
  
}

model TableB {
  objectId    String @id
  foo         String
}
I know what we're doing there is pretty weird, i.e., using the name we want for the relational field for the ID in our database...We're working with (and trying to replace) a legacy system, but we would prefer to use the names as expected. Is there a way to achieve this?