Skip to content

Get requested fields in resolve function #57

Closed
@Globegitter

Description

@Globegitter

I have seen that the info parameter in the resolve function provides a info.field_asts, which provides information about the selected fields, but when fragments are provided you get something like:

[Field(alias=None, name=Name(value=u'customer'), arguments=[], directives=[], selection_set=SelectionSet(selections=[Field(alias=None, name=Name(value=u'id'), arguments=[], directives=[], selection_set=None), FragmentSpread(name=Name(value=u'__RelayQueryFragment0wau8gf'), directives=[])]))]

which means for fragments we can't really figure out which fields are selected at runtime.

Our use-case for knowing the fields in the resolve functions is,that we only want to calculate the fields that are actually requested because some of the fields are expensive to calculate.

Edit: Or are the resolve methods for specific fields meant to be used for that? E.g. resolve_full_name on the Customer node?

Also happy to provide an example of that would make it easier.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions