nuwave / nuwave/lighthouse

@canResolved directive action ignored when batchload_relations enabled

Open
#2,758 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description

When batchload_relations enabled in config file, and @canResolved is used for a relation the action: RETURN_VALUE will be ignored.

Expected behavior/Solution

When model's policy returns false and action = RETURN_VALUE, is set to null expectation is that it will return null instead of the This action is unauthorised

Steps to reproduce

GraphQL:

type User {
    book: Book @belongsTo @canResolved(ability: "view", action: RETURN_VALUE, returnValue: null)
}

type Query {
    users(): [User] @canResolved(ability: "view") @paginate
}

Lighthouse Version

v6.65.0

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 reproducing the GraphQL schema shown with batchload_relations enabled and a policy returning false. Trace @canResolved handling for the relation and action RETURN_VALUE; done when the relation resolves to null rather than returning the unauthorised error.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, laravel, php
Domain
api, authorization, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.