-
Notifications
You must be signed in to change notification settings - Fork 202
Fix entity reference language #1232
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
Fix entity reference language #1232
Conversation
# Conflicts: # src/Plugin/GraphQL/DataProducer/Field/EntityReference.php # src/Plugin/GraphQL/DataProducer/Field/EntityReferenceRevisions.php
…ntityReferenceLayoutRevisions
b6fc386
to
d68443a
Compare
d68443a
to
6320702
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a code perspective it seems fine. As I understand we will fall back to the source language if a language does not exist? Then it's up to the consumer to decide what to do. An option for "strict" language (only return items that exist in that language) could he helpful, but i would not put it in scope of this PR.
But we also need some tests for that. We only have one entity reference test right now:
https://github.com/drupal-graphql/graphql/blob/8.x-4.x/tests/src/Kernel/DataProducer/FieldTest.php
And it's weirdly named? Maybe we could use this as an opportunity to name it properly and add cases for this fix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed with @pmelab , tests would be good to cover the language. And we should use type hints in function signatures for all new code.
@pmelab @klausi I guess this is out of scope, but there seems to be an issue with the data producer argument default values. For example, the graphql/src/Plugin/GraphQL/DataProducer/Field/EntityReference.php Lines 46 to 50 in 6961eac
So I would guess that the However, it is typehinted as
Then, when we call I would suggest:
|
Does the incorrect default value behavior apply to actual execution within a schema request? Or is it scoped to |
No. With a real request, the default values are set from the plugin definition (here).
Yes. But this method is used a lot in tests. |
Well, yeah... If a data producer is extended from outside of the module, things might break. |
@klausi Do we consider a typehint change that will invalidate subclasses a breaking change? I can't tell if a lot of people extend existing resolvers. |
It depends if we consider data producer plugins as part of the API surface of graphql module or not. I'm not sure, when in doubt we should probably consider it as part of the stable API and we cannot change it. I think we are lucky here and do not have a security issue since in real requests the access default value gets filled in correctly as you found out. Anyway, I think it makes sense to improve DataProducerExecutionTrait in the test to fill in default values if possible |
Thanks a lot @Leksat ! I merged this now and we can follow-up with DataProducerExecutionTrait default value test improvements. |
* 8.x-4.x: fix(dataproducer): Fix language definition to be single value in entity reference producers (drupal-graphql#1241) docs(server): Improved class property descriptions feat(server): Add configurable validation security rules for introspection and query complexity (drupal-graphql#1244) tests(buffer): Fix ArryObject usage to not depend on Zend (drupal-graphql#1247) test(phpstan): Add missing return type hint fix(file-upldoad): Validate files in the correct order fix(DataProducer): Fix entity reference loading by language (drupal-graphql#1232) tests(assertions): Implement leaked metadata detection for QueryResultAssertionTrait (drupal-graphql#1207) tests(github): Switch testing to Drupal core 9.2.x (drupal-graphql#1215) chore(voyager): yarn audit security updates (drupal-graphql#1214) test(phpstan): Enable PHPStan run on PHP 8.0 (drupal-graphql#1211) refactor(executor): Replace deprecated AST::getOperation() with AST::getOperationAST() (drupal-graphql#1210) fix(executor): Remove swapped errors compatibility mode
Fixes
entity_reference
,entity_reference_layout_revisions
andentity_reference_revisions
data producers. Now they return the translated entities in case if language is provided.Based on @drupov's PR #974