This project is not covered by Drupal’s security advisory policy.

GraphQL Field Formatters and renderer helpers for fields.
Applies to GraphQL 3.x only.

Use case

When it makes sense to delegate the rendering to Drupal.

Examples:

  • delegate sanitizing to Twig instead of a Javascript library
  • delegate the rendering of complex data structures (e.g. paragraphs) to Drupal
  • in combination with GraphQL Twig
  • in a progressively decoupled setup, where markup is shared between decoupled
    / non decoupled components for styling.

For helpers like:

  • Text summary: truncate or reuse the field summary if available
  • Plain text: strip tags of formatted texts
  • Drupal date format
  • Currency
  • ...

Already supported by GraphQL 3.x core

You might not need this module for these use cases,
supported by the Drupal GraphQL core:

  • Format a date with inline format: entityCreated(format: "d/m/Y")
  • Render an entity with a view mode: entityRendered(mode: TEASER)
  • Image styles
  • ...

Dependencies

GraphQL 8.3.x

View Mode based Field Formatter

WIP, does not support all data types.

Inherits from the view mode configuration of the entity bundle.

Example:

query {
  nodeQuery {
    entities {
      ... on NodeArticle {
        fieldTextFormatted {
          viewModeFieldFormatter(mode: TEASER)
        }
      }
    }
  }
}

Settings based Field Formatter

WIP

Instead of inheriting from the view mode configuration, the
settings from the field are passed.

Example:

query {
  nodeQuery {
    entities {
      ... on NodeArticle {
        fieldTextFormatted {
          fieldFormatter(settings: {
            label: "hidden",
            trimmed: 600
          })
        }
      }
    }
  }
}

Other field based helpers

Text summary

WIP

query {
  nodeQuery {
    entities {
      ... on NodeArticle {
        fieldTextFormatted {
          textSummary(max_chars: 300)
        }
      }
    }
  }
}

Date based on the date formats (e.g. short, medium) - GraphQL Date

WIP

Currency formatter

WIP

Supporting organizations: 

Project information

  • caution Minimally maintained
    Maintainers monitor issues, but fast responses are not guaranteed.
  • caution Maintenance fixes only
    Considered feature-complete by its maintainers.
  • Project categories: Decoupled
  • Ecosystem: GraphQL
  • Created by colorfield on , updated
  • shield alertThis project is not covered by the security advisory policy.
    Use at your own risk! It may have publicly disclosed vulnerabilities.

Releases