graphql_format_name

graphql_format_name( string $name, string $replacement = '_', string $regex = '/[^A-Za-z0-9_]/i' ): string;

Formats a string for use as a GraphQL name. Per the GraphQL spec, characters in names are limited to Latin ASCII letter, digits, or underscores.

  • Since: v1.17.0
  • Source File: plugins/wp-graphql/access-functions.php

Parameters

  • $name (string): The name to format.
  • $replacement (string): The replacement character for invalid characters. Defaults to ’_‘.
  • $regex (string): The regex to use to match invalid characters. Defaults to ’/[^A-Za-z0-9_]/i’.

Return

  • string: The formatted name, safe for use as a GraphQL name.

Source

function graphql_format_name( string $name, string $replacement = '_', string $regex = '/[^A-Za-z0-9_]/i' ): string {