Scope on morphTo directive applied to source model, rather than target
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 3.5k
- Forks
- 468
- Avg merge
- 3h 9m
- Merged PRs (30d)
- 2
Description
Describe the bug
When applying a scope to the morphTo directive, it appears that Lighthouse is trying to apply the scope to the root model, rather than then target relationship. For instance, given the following schema:
type Author {
id: ID!
publications: [Publication!]!
}
type Publication {
id: ID!
publication: Publishable @morphTo(scopes: ["active"])
}
type Magazine {
id: ID!
title: String!
isActive: Boolean!
}
type Book {
id: ID!
title: String!
isActive: Boolean!
}
union Publishable = Book | Magazine
Lighthouse is trying to apply the active scope to the Publication model, rather than the Magazine or Book model.
Expected behavior/Solution
The scope should be applied to the query responsible for fetching the Magazine or Book.
Steps to reproduce
See above example.
Lighthouse Version
v5.23.1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the supplied Author, Publication, Magazine, and Book schema with the morphTo directive and active scope. Trace the morphTo scope handling to determine why the source model receives the scope instead of the target query. Done means active filters the Magazine or Book result and the behavior is covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, laravel, php
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100