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

NEW: Refactor OperationScaffolder subclasses to use resolved type name #182

Merged
merged 1 commit into from
Jan 30, 2019

Conversation

unclecheese
Copy link

Resolves: #176

@tractorcow
Copy link
Contributor

The problem with this is that getTypeName() / getResolvedTypeName() both ignore PREFER_UNION which requires the manager to resolve. getType()->name could still be different to either of the return values of those methods.

On the other hand, it's still not worse than the status quo, it just doesn't address the inconsistencies.

I also thought about binding manager to the types directly, so we have a getManager() on the scaffolders instead of having to pass it in.

@tractorcow
Copy link
Contributor

Also, we should be careful about "We have 5 methods to get the type name so fix it by adding a 6th". :P

Copy link
Contributor

@maxime-rainville maxime-rainville left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this locally by implementing a simple graphql service in framework test. I've tested:

  • letting the typename be inferred from the DataObject name,
  • specifying different typenames via a typeNames map on the Manager YML config,
  • explicitly specifying a typename via a scaffolding_providers implementation.

I think @tractorcow concern is partially mitigated by making the new methods protected. ResolveTypeName and getDataObjectTypeName are mostly implementation details that you don't need to be aware off when interacting with the scaffolder classes.

*
* @return string
*/
protected function typeName()
public function getDataObjectTypeName()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be public? From the usage above, it looks like this is mostly dealing with internal logic consideration.

If it turns out we need it to be public later, it's easy to make it public.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a @throws statement.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, but would make this an API breakage, and since it's essentially a bug fix, I really would love to get it into 3.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this an API breakage? There's no getDataObjectTypeName right now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And introducing APIs to fix bugs is fine in Semver.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the protected method is risky but also fine in terms of semver. They're not part of our "public API"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is targeted at version 3. Which hasn't been release yet. Or do we consider RC to be part of our semver commitment?

@maxime-rainville
Copy link
Contributor

FYI I was using this PR on FrameworkTest.

@unclecheese unclecheese merged commit 2e4b121 into silverstripe:3 Jan 30, 2019
@unclecheese unclecheese deleted the pulls/3/not-my-type branch January 30, 2019 01:59
unclecheese pushed a commit that referenced this pull request Mar 4, 2019
chillu pushed a commit that referenced this pull request Mar 14, 2019
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.

5 participants