Improve submitWebform mutation to support backend validation and entity association

Created on 26 June 2025, 16 days ago

Problem/Motivation

The submitWebform mutation provided by the graphql_compose_webform module currently lacks two important features for production use:

  1. Validation: It does not trigger backend validation rules defined on individual webform elements. As a result, required fields, input patterns, and other constraints may be bypassed when submitting via GraphQL.
  2. Entity association: It does not associate the submission with the host entity (e.g., a node) where the webform is attached. This makes it difficult for editors and administrators to view and filter submissions based on the context in which they were submitted.

Expected Behavior

  • The mutation should validate all form elements server-side using the Webform validation system.
  • If validation fails, the mutation should return structured error messages (e.g., per field).
  • The mutation should allow passing an entity_type and entity_id so the submission is properly linked to the entity where the webform is rendered.

Proposed resolution

  • Refactor the submitWebform producer to invoke Webform’s internal validation and submission handling (e.g., using WebformSubmissionForm::validateWebformSubmission()).
  • Add support for passing entity_type and entity_id as input to the mutation.
  • Store the entity reference using the webform_submission.entity_type and webform_submission.entity_id fields as Webform expects.
  • Update the GraphQL schema accordingly.
Feature request
Status

Active

Version

1.4

Component

Code

Created by

🇧🇪Belgium bernardopaulino Brussels

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024