drupal-graphql / drupal-graphql/graphql

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

Open
#1,234 0 comments 0 reactions 0 assignees View on GitHub
4.x documentation
Dominant language
PHP
Stars
287
Forks
198
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.