Skip to content

When using fragments, executor resolves a property that is not going to be returned #197

@thevietto

Description

@thevietto

given the following schema:

query("outer") {
    resolver { ->
        Outer(Inner("test"))
    }
}
type<Inner> {
    property("testProperty") {
        resolver { "this should be resolved" }
    }
    property("unwantedProperty") {
        resolver {
            "This code should not be executed as it could be an expensive calculation" // <--- here
        }
    }
}

and the following query:

{
    outer {
        ...TestFragment
        inner { testProperty } # override what declared in TestFragment, return only `testProperty`
    }
}
fragment TestFragment on Outer {
    inner { name, testProperty, unwantedProperty }
}

we got the following result, which is fine (or is it?):

{"data":{"outer":{"inner":{"testProperty":"this should be resolved"}}}}

The issue is, the unwantedProperty resolver is still getting executed because that field is declared in TestFragment.
Expected behavior is that this resolver is ignored because it is not requested by caller

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions