Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support defining enum values by callable and/or generator #971

Merged
merged 2 commits into from
Dec 23, 2021

Conversation

ruudk
Copy link
Contributor

@ruudk ruudk commented Dec 23, 2021

This PR adds support for the new feature merged in webonyx/graphql-php#1040.

It allows returning enum values by closure and/or generator.

While working on this I also noticed that the object decorator doesn't work properly when the objects fields are returned by a generator. That's now fixed as well.

I had to add a PHPStan ignore line because of this issue: webonyx/graphql-php#1041

@ruudk ruudk requested a review from mcg-web December 23, 2021 19:28
When an `ObjectType` uses a Generator to provide the `fields`, the decorator fails with:
```
Exception : You can only iterate a generator by-reference if it declared that it yields by-reference
```

Therefore, we convert the iterator to an array and modify it, and then return the array.
@mcg-web mcg-web merged commit a43a26e into overblog:master Dec 23, 2021
@mcg-web
Copy link
Member

mcg-web commented Dec 23, 2021

Thank you @ruudk !

@ruudk ruudk deleted the generator-callable branch December 24, 2021 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants