nuwave / nuwave/lighthouse

Eager-load multiple relationships through `@with`

Open
#1,132 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
PHP
Stars
3.5k
Forks
468
Avg merge
3h 9m
Merged PRs (30d)
2

Description

Is your feature proposal related to a problem? Please describe.

It seems that it is currently not possible to eager-load multiple relationships through the @with directive.

Describe the solution you'd like

I think it should either be possible to use the @with directive more than once on a single field, or the @with directive should accept an array of relationships.

  • Using the @with directive multiple times: I'm not sure if it's currently possible to use any directive more than once on a single field. Is this being prevented for some reason?
  • Accepting an array of relations through the @with directive: The question is how to handle scopes then, should they be part of the relations array (e.g relations: ["relation" => ["scopeOne", "scopeTwo"]]?

Describe alternatives you've considered

I haven't found any alternative to overcome this issue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the implementation and tests for the @with directive and how a single relationship is currently specified. Compare the two proposed forms, including scoped relationships, and define which behavior and tests would establish support for multiple eager-loaded relationships.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, laravel, php
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.