LoginSignup
0
0

More than 5 years have passed since last update.

GraphQLので階層構造のモデルを作る

Posted at

簡単ですよ。

1対Nの場合、こちら。

@relationアノテーションで2つのFieldが紐づけられております。

このとき、片方がTest(単体)、片方が[Locations!]!(複数)であることが大事です。

今回使ったPrismaは、片方が複数、ということが理解できないと「1対N」と理解できません


type Location {
  address: String!
  country: String!
  test: Test @relation(name: "TestOnLocation")
}

type Test {
  id: ID! @unique
  test: String! @unique
  locations: [Location!]! @relation(name: "TestOnLocation")
}

そして階層構造を一括操作するクエリは、Prismaの場合こちら

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0