mirror of
https://github.com/retailcrm/graphql-php.git
synced 2025-02-16 20:33:14 +03:00
Sanity check to ensure that GraphQL query is string
This commit is contained in:
parent
3f909e3e11
commit
34ca931533
@ -18,7 +18,7 @@ class GraphQL
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param Schema $schema
|
* @param Schema $schema
|
||||||
* @param $requestString
|
* @param string|DocumentNode $requestString
|
||||||
* @param mixed $rootValue
|
* @param mixed $rootValue
|
||||||
* @param array|null $variableValues
|
* @param array|null $variableValues
|
||||||
* @param string|null $operationName
|
* @param string|null $operationName
|
||||||
@ -41,7 +41,7 @@ class GraphQL
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Schema $schema
|
* @param Schema $schema
|
||||||
* @param $requestString
|
* @param string|DocumentNode $requestString
|
||||||
* @param null $rootValue
|
* @param null $rootValue
|
||||||
* @param null $variableValues
|
* @param null $variableValues
|
||||||
* @param null $operationName
|
* @param null $operationName
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace GraphQL\Language;
|
namespace GraphQL\Language;
|
||||||
|
|
||||||
|
use GraphQL\Utils;
|
||||||
|
|
||||||
class Source
|
class Source
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -20,6 +22,11 @@ class Source
|
|||||||
|
|
||||||
public function __construct($body, $name = null)
|
public function __construct($body, $name = null)
|
||||||
{
|
{
|
||||||
|
Utils::invariant(
|
||||||
|
is_string($body),
|
||||||
|
'GraphQL query body is expected to be string, but got ' . Utils::getVariableType($body)
|
||||||
|
);
|
||||||
|
|
||||||
$this->body = $body;
|
$this->body = $body;
|
||||||
$this->length = mb_strlen($body, 'UTF-8');
|
$this->length = mb_strlen($body, 'UTF-8');
|
||||||
$this->name = $name ?: 'GraphQL';
|
$this->name = $name ?: 'GraphQL';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user