forked from wp-graphql/wp-graphql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccess-functions.php
executable file
·38 lines (35 loc) · 1.06 KB
/
access-functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?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 );
}