Skip to content

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

@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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Kingdutch@dottodot

        Issue actions

          How to use $builder->context and $builder->fromContext · Issue #1234 · drupal-graphql/graphql