strawberry-graphql / strawberry-django

Strawberry GraphQL Django extension
MIT License
391 stars 115 forks source link

feat: Avoid joins when only fetching an ID #483

Open mselee opened 4 months ago

mselee commented 4 months ago

Description

Consider the following query

query Query {
  books {
    id
    author {
      id
    }
  }
}

A join will be generated even though we really don't have to, as the required information already exists through book.author_id. The idea here is to try and optimize away this join, by constructing the Author object in-memory using the value from book.author_id.

I'm not very familiar with the code base, so I'm not sure if this is has other drawbacks.

Types of Changes

Checklist

Sanyambansal76 commented 3 months ago

@mselee want to check if you are waiting for help to update the PR?