API Don't create "peripheral" operations by default #206
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When scaffolding Page with a read operation,
the default behaviour used to be the creation of readPage, readSiteTree, readRedirectorPage etc.
In fact, the readPage query is sufficient, since it returns a union of all these types. The rest is noise,
with the slight advantage that types at the end of an inheritance chain (without descendants)
get away without unions in the return type.
The default behaviour is a bit more useful on create and update operations,
since those require a specific input type - unions aren't allowed here.
So in order to fully create subclasses, you need createPage vs. createRedirectorPage.
I'm proposing that we make this well-documented opt-in behaviour,
with the admin/graphql schema opting in for each type on create and update.
I don't see a reason why anyone would want to opt in on read or delete.
For the more common case where scaffolding is used to create a more limited readonly public schema,
this reduces the mental overhead for devs, noise in the schema itself,
and cuts down schema generation time because less "helper types" like readRedirectorPageConnectionType are required.
If this PR is accepted, we'll need to add the following to the
upgrading guide at https://github.com/silverstripe/silverstripe-graphql/releases/edit/untagged-b4d095bafd3edac22f15
Previously, scaffolded operations on
DataObject
wouldcreate the equivalent operations on both ancestors and descendants.
If you want
readPage
, you'd also getreadSiteTree
andreadRedirectorPage
.That's often not desired, so we're making it opt-in via a new
cloneable
config setting.Note that it's most common to clone
create
andupdate
operations,since those rely on specific input types for a class
(e.g.
createPage
hascreatePageInputType
, whilecreateRedirectorPage
hascreateRedirectorPageInputType
).