Open pmelab opened 3 years ago
How I got here: While researching #724 , it occurred to me that we could use the information in the schema.
type Image @gutenberg(blockName: "custom/image") {
media: Media! @media
caption: String @property('title')
}
Could already tell a validation step which parts of a block are required.
Current situation
The
silverback-gatsby
schema extension generates some types and fields based on directives in the schema:@entity
id
,translations
andlangcode
for each type annotated with@entity
id
anditems
for types annotated with@menu
id
andparent
for types that are set asitem_type
in a@menu
directiveProblem
drush sgse
) to generate the full schema to be able to feed it into other systems, likecodegen
for frontend queries.The exception are the root-level fields for Gatsby. In my opinion they can stay this way, since they are not used by another system and tightly bound to the implementation, and therefore the application should not be in control and/or use these fields for anything else. I would go as far as marking them as
@deprecated
Suggestion
Follow the path that was outlined by the
@property
directive. Make all fields explicit:We could provide the basic API for schema extensions to scan for combinations of certain type and field annotations and generate resolvers based on that. That would make it easier to add directives in the future: