Files

39 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2018-06-25 00:00:37 +02:00
<?php
/**
* This file contains access functions for various class methods
*
* @since 0.0.2
*/
/**
* Formats the name of a field so that it plays nice with GraphiQL
*
* @param string $field_name Name of the field
*
* @access public
* @return string Name of the field
* @since 0.0.2
*/
function graphql_format_field_name( $field_name ) {
$field_name = preg_replace( '/[^A-Za-z0-9]/i', ' ', $field_name );
$field_name = preg_replace( '/[^A-Za-z0-9]/i', '', ucwords( $field_name ) );
$field_name = lcfirst( $field_name );
return $field_name;
}
/**
* Provides a simple way to run a GraphQL query with out posting a request to the endpoint.
*
* @param string $request The GraphQL query to run
* @param string $operation_name The name of the operation
* @param string $variables Variables to be passed to your GraphQL request
*
* @access public
* @return array
* @since 0.0.2
*/
function do_graphql_request( $request, $operation_name = '', $variables = '' ) {
return \WPGraphQL::do_graphql_request( $request, $operation_name, $variables );
}