Hey! I jumped a few versions up in prisma (from 1....
# orm-help
l
Hey! I jumped a few versions up in prisma (from 1.7 to 1.27) and I’m looking for help. I have problem with quering data with relations. I’m using
javascript-client
and previously was using
graphql-binding
. So, previously I was using this to grab data with all the relationships underneath
Copy code
await ctx.db.query.accounts({
      where: { user: { id }, role },
      orderBy: 'createdAt_ASC',
      last: 1,
    }, `{
      contact { phone, phone2, skype, address }
    }`)
datamodel
Copy code
type User {
  id: ID! @unique
  createdAt: DateTime!
  updatedAt: DateTime!

  accounts: [Account!]! @relation(name: "UsersAccount")
}

type Account {
  id: ID! @unique
  createdAt: DateTime!
  user: User! @relation(name: "UsersAccount")

  role: Role!
  contact: Contact @relation(name: "AccountsContact")
}

type Contact {
  id: ID! @unique
  updatedAt: DateTime!
  account: Account! @relation(name: "AccountsContact")

  phone: String!
  phone2: String
  skype: String
  address: String!
}
now, going from
ctx.db.query.accounts
to
ctx.db.accounts
results in empty relations data. How should I call it so it returns the relations data properly for me?
h
You will require to manually resolve it
in the type resolver
l
Any idea why can't it be resolved automatically? I returned to graphql-bindings since it was too much hassle to change it now
h
If you want bindings like features use Nexus https://github.com/prisma/nexus-prisma
This makes things even easier than bindings