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
API: Customise type names and operation names #143
API: Customise type names and operation names #143
Conversation
583eaaa
to
87fce2b
Compare
b4d7191
to
a0bd07c
Compare
@unclecheese please rebase on 1 branch. master is for framework 5.x compat, and we want this in 4.2 |
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.
Please rebase (see comment)
Change of plan, we're branching master into 2 and will adjust master to 3.x (for framework 5.x compat). |
The new API seems very out of sync with the existing scaffolding config. For instance, this is how a type of
Why isn't typeName simply a property on one of these nested values, and instead is shifted to the
At the moment we are branching a new major version specifically for a simple class rename and shifting a static accessor into an instance method. For a new major version I would like to see the API break in a way that promotes cohesion rather than additional fragmentation. |
In addition, we haven't got any similar support for the php api scaffolding. Could we enable object / operation naming as such? $scaffolder
->type(Post::class)
->setTypeName('MyPost')
->addFields(['ID', 'Title', 'Content'])
->operation(SchemaScaffolder::READ)
->setTypeName('readMyPosts')
->end()
->operation(SchemaScaffolder::UPDATE)
->setTypename('updateMyPost')
->end()
->end(); |
Summary from offline discussion with @tractorcow:
$scaffolder->type(BlogPost::class)
->fields(['ID', 'Author']) // author now exposed. its typename must be deterministic
->end()
->type(Member::class)
->setTypeName('MySpecialMember') // oh no!
class Manager {
public static function createFromConfig($config) {
Schema::inst()->setTypeNames($config['typeNames']);
}
} |
Yep turns out it's not that easy is it! You're right we do need to pre-define this mapping before we can scaffold anything. |
Also please fix up the docs on the yml / php methods for naming of operations. Make sure the YML examples you give include the entire config tree, not just a subtree, since users reading it won't know My\Really\Long\Namespaced\DataObject:
operations: needs to be nested inside SilverStripe\GraphQL\Controller:
schema:
scaffolding:
types: |
@unclecheese a question about subclasses. Lets say we scaffold If someone subclasses |
Ok I've pushed up what I think gets this over the line:
|
Note: Tests are all messed up. A problem for tomorrow. :) |
f33dd36
to
f8d63b9
Compare
Merged 1 -> 2, 2 -> master, rebased this on 2. Some errors surfaced. Am looking into them. |
ENHANCEMENT Bootstrap StaticSchema from Manager::createFromConfig BUG Fix StaticSchema inst not persisting DOCS Update docs for how to use class map
727f3ba
to
28df271
Compare
…ing-warning-warning Fix linting warnings in sass
Resolves #95