Skip to content

Scope on morphTo directive applied to source model, rather than target #2106

@dennis-koster

Description

@dennis-koster

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn error within Lighthouse

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions