-
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
NEW: DBField arguments, Enum, Composite support #398
NEW: DBField arguments, Enum, Composite support #398
Conversation
Failed build is due to a branch pushed to origin that was later deleted. |
a7c9cca
to
af72974
Compare
b4c64c4
to
2baad90
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.
Looking good
I don't have enough context to really challenge the approach taken here, so I'll just assume it's a great idea :-)
Allowing php formatting to be specified via a graphql query is certainly interesting. It does seem slightly wrong since usually that's supposed to happen client side, though I personally think it's a good convenience and it facilitates code reuse.
I've left some comments around some opportunities to tidy up the code
Co-authored-by: Steve Boyd <emteknetnz@gmail.com>
Resolves
Summary
This pull request adds three new plugins to better support
DBField
types.Example
DBFieldArgsPlugin
format
argument to DBField types that have formatting methods, e.g.FirstParagraph
. (content(format: FIRST_PARAGRAPH) )
limit
argument is added, e.g.content(format: LIMIT_SENTENCES, limit: 5)
format
argument for date / time fields, e.g.lastEdited(format: DAY_OF_WEEK)
DBFieldTypes plugin
DBEnum
creates a properEnum
type in the schema, and gets assigned to the fieldDBFile
create proper object types in the schema and get assigned to the fieldScalarDBField plugin
New low-level stuff
Default DataObject resolver no longer normalises to scalars: The above changes required changing the default DataObject resolver to no longer return
$dbField->getValue()
(scalar) and rather leave the instance in tact so the other resolvers could act upon it (e.g. $obj->FirstParagraph()). There is now a plugin that runs at the end of the resolver stack that ensures if the object is DBField, it will run->forTemplate()
on it to extract its scalar valueModelField
now accepts ametadata
property. This may be a bit overkill, but we needed a place to store state on how the field was created, e.g. from introspection of a DBField. (->getMetadata()->get('dataClass')
). As yet there are no other uses for this storage, but it's conceivable that other plugins or future features will want to add arbitrary state to fields.Schema config now has a
parseShortcodes
property as a global setting forDBHTMLText
fields. (false in admin, true in default). This can also be set per field inmyHTMLField(parseShortcodes: false)
Type
DBFile
no longer exists. It's created by theDBFieldTypes
plugin automatically asDBFileComposite
Docs
silverstripe/silverstripe-framework#10039
Relevant, but not necessarily dependent