Problem/Motivation
Found while validating paragraph scaffolding (#3613218) on a site running graphql_compose_webform with a p_webform paragraph bundle. The contrib webform field type has no FieldTypeMapper plugin, so a webform reference field scaffolds as:
webform # TODO: add sub-selection for type unknown
and the TypeScript property is typed unknown. The TODO path is working as designed for unmapped types, but webform is common enough on headless sites to deserve a real mapping.
Proposed resolution
Add a WebformMapper FieldTypeMapper plugin claiming the webform field type. graphql_compose_webform exposes a stable shape that hand-written frontends already query:
webform { id label description elements { webform_key type title required placeholder description options { id value } } }
The mapper would emit a DrupalWebform-style TS type and TypeScriptGenerator::getGqlSelector() would emit the matching sub-selection. The selection should only be emitted when graphql_compose_webform provides it — otherwise keep the current TODO fallback.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | graphql_compose_codegen-webform-mapper-3613232-2.patch | 13.63 KB | jmcerda |
Comments
Comment #2
jmcerdaImplemented: https://github.com/Wilkes-Liberty/graphql_compose_codegen/pull/18 (branch
3613232-webform-mapper, targeting 1.x). Patch against 1.x attached.- New WebformMapper plugin:
webformmaps toDrupalWebform(DrupalWebform[]for multi-value storage).- Fragments select the graphql_compose_webform shape:
webform { id label description elements { webform_key type title required placeholder description options { id value } } }.- The types artefact appends the
DrupalWebform/DrupalWebformElement/DrupalWebformElementOptionhelper types whenever an emitted bundle has a webform field, so the scaffold is self-contained.One deliberate deviation from the proposal above: the mapping is unconditional rather than gated on graphql_compose_webform being installed. That matches every other mapper (none gate on schema exposure), and the graphql_compose enabled-field filtering from #3613218 already keeps unexposed fields out of the scaffold.
Covered by unit tests for the mapper and a kernel fixture with a real webform field asserting the selection and helper types.
drupal/webform ^6.3@RCadded to require-dev and both CI pipelines (6.2 does not support Drupal 11). phpcs and phpstan pass.Comment #4
jmcerdaShipped in 1.1.0.