parseValue() public static method

Throws GraphQLError if a syntax error is encountered. This is useful within tools that operate upon GraphQL Values directly and in isolation of complete GraphQL documents. Consider providing the results to the utility function: valueFromAST().
public static parseValue ( Source | string $source, array $options = [] ) : BooleanValueNode | EnumValueNode | FloatValueNode | IntValueNode | ListValueNode | ObjectValueNode | StringValueNode | VariableNode
$source Source | string
$options array
return GraphQL\Language\AST\BooleanValueNode | GraphQL\Language\AST\EnumValueNode | GraphQL\Language\AST\FloatValueNode | GraphQL\Language\AST\IntValueNode | GraphQL\Language\AST\ListValueNode | GraphQL\Language\AST\ObjectValueNode | GraphQL\Language\AST\StringValueNode | GraphQL\Language\AST\VariableNode
Exemplo n.º 1
0
 /**
  * @it parses list values
  */
 public function testParsesListValues()
 {
     $this->assertEquals(['kind' => NodeKind::LST, 'loc' => ['start' => 0, 'end' => 11], 'values' => [['kind' => NodeKind::INT, 'loc' => ['start' => 1, 'end' => 4], 'value' => '123'], ['kind' => NodeKind::STRING, 'loc' => ['start' => 5, 'end' => 10], 'value' => 'abc']]], $this->nodeToArray(Parser::parseValue('[123 "abc"]')));
 }
Exemplo n.º 2
0
 private function runTestCaseWithVars($variables, $type, $valueText, $expected)
 {
     $this->assertEquals($expected, AST::valueFromAST(Parser::parseValue($valueText), $type, $variables));
 }