2
graphQL-ruby를 사용하면서 기존 ActiveRecod .includes를 연관된 모델로 변환하는 방법에 대한 예제를 찾고 있었지만 찾을 수 없었습니다. 사용 사례로 , 이제 우리는 다음과 같은 모델을 가정 해 봅시다 :은 graphql-ruby로/eager load 관련 모델을 포함합니다.
User
has_many :books
Book
belongs_to :user
has_many :chapters
Chapter
belongs_to :book
has_many :pages
Page
belongs_to :chapter
우리가 구현할 수있는 방법은 다음과
User.includes(books: {chapters: :pages})
실제 중첩 GraphQL 쿼리는 비교적 간단하다; 그러나, 그것은 N + 1에서 실행중인 것 같습니다.
도움을 주시면 감사하겠습니다.