Skip to content

How to use $builder->context and $builder->fromContext #1234

Open
@dottodot

Description

@dottodot

There doesn't seems to be any documentation for this but the comments it seems to suggest you can set a context in one resolver and retrieve that value later on in another resolver, i was hoping something like the following but it doesn't work

        $registry->addFieldResolver(
            'ImageGridParagraph', 'style',
            $builder->compose(
                $builder->produce('property_path')
                    ->map('type', $builder->fromValue('entity:paragraph'))
                    ->map('value', $builder->fromParent())
                    ->map('path', $builder->fromValue('field_image_focal_point_styles.value')),
                $builder->context(
                    'image-grid-style', $builder->fromParent()
                ),
            )
        );
        $registry->addFieldResolver(
            'Image', 'parentStyle',
            $builder->compose(
                $builder->fromContext('image-grid-style'),
            )
        );

I want to pass a value a couple of levels down a nested structure

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions