Automattic\WooCommerce\Internal\Api

QueryCache::parseprivateWC 1.0

Parse a query and return the DocumentNode, or a GraphQL-shaped error array if the query has a syntax error.

Method of the class: QueryCache{}

No Hooks.

Returns

DocumentNode|Array.

Usage

// private - for code of main (parent) class only
$result = $this->parse( $query );
$query(string) (required)
The GraphQL query string.

QueryCache::parse() code WC 10.9.4

private function parse( string $query ) {
	try {
		return Parser::parse( $query, array( 'noLocation' => true ) );
	} catch ( \Automattic\WooCommerce\Vendor\GraphQL\Error\SyntaxError $e ) {
		return $this->error_response( 'GraphQL syntax error: ' . $e->getMessage(), 'GRAPHQL_PARSE_ERROR' );
	}
}