-
Notifications
You must be signed in to change notification settings - Fork 61
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 QueryScaffolder not using inheritance types #176
Fix QueryScaffolder not using inheritance types #176
Conversation
@@ -85,7 +85,7 @@ public function getTypeName() | |||
protected function getType(Manager $manager) | |||
{ | |||
// If an explicit type name has been provided, use it. | |||
$typeName = $this->getTypeName(); |
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.
If getTypeName() is returning the wrong value, I wonder if we can fix it there?
This logic defers auto-type scaffolding from StaticSchema, which may in some cases be the correct behaviour. It fixes one use case but breaks others.
It seems like the fundamental problem is "typeName" can't be determined without a manager. In that case, this issue is a symptom of a fundamental problem of manager-gnostic type resolution.
Looking back at 7c3980a, it seems like we introduced prefer_union = true.
Perhaps that logic needs to be available to getTypeName() as well, so it returns the union type name?
Do both getType() / getTypeName() need manager to be present?
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.
What Damian said.
The follow up discussion on this happened on Slack: tl;dr rewrite all these methods to be more semantically correct.
|
The ideal fix for this involves refactoring that is much more appropriate for the |
Issue is that typeName() from DataObjectTypeTrait bypasses the logic in StaticSchema::fetchFromManager() Solution is to add getResolvedTypeName() that uses the manager to resolve the name always. Suggestion:
|
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.
As per last comment.
A more thorough fix, with API changes is against the I don't see the case for passing It gets really confusing, and I've tried to clean up the semantics a bit in the
|
@ScopeyNZ @robbieaverill We got a bit of a deadlock on this one and we're not quite sure how to proceed. Would you care to throw your two cents on this? |
I'm not familiar enough with this part of the code TBH. I can say that it's preventing us from using dynamic fragments, which we'll need to start using at some point for the CWP modules. It's also come up in Stackoverflow, and apparently this PR fixes the problem: https://stackoverflow.com/questions/53184168/silverstripe-graphql-error-when-querying-types-with-descendants My assumption is that the blocking comments here are mostly semantic |
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.
Following some back and forth. I'm OK with this being merge.
Calling parent::getTypeName()
from getType()
is weird, but in the context that this is a low level abstract class and that this will only affect the 2 branch we can probably live with it.
Lack of response, approved by another core commmiter
Sorry @unclecheese I'll just leave this to you. I don't have much time these days to get too deep into graphql. =( |
Other pull requests
For the
3
branch fix: