protected function parseAndCreateRequest($payload, $variables = []) { if (empty($payload)) { throw new \InvalidArgumentException('Must provide an operation.'); } $parser = new Parser(); $request = new Request($parser->parse($payload), $variables); (new RequestValidator())->validate($request); $this->executionContext->setRequest($request); }
public function testContainer() { $container = new Container(); $container->set('user', ['name' => 'Alex']); $executionContext = new ExecutionContext(new Schema(['query' => new ObjectType(['name' => 'RootQuery', 'fields' => ['currentUser' => ['type' => new StringType(), 'resolve' => function ($source, $args, ResolveInfo $info) { return $info->getContainer()->get('user')['name']; }]]])])); $executionContext->setContainer($container); $this->assertNotNull($executionContext->getContainer()); $processor = new Processor($executionContext->getSchema()); $processor->getExecutionContext()->setContainer($container); $this->assertEquals(['data' => ['currentUser' => 'Alex']], $processor->processPayload('{ currentUser }')->getResponseData()); }
public function __construct(AbstractSchema $schema) { $validator = ConfigValidator::getInstance(); $validator->addRule('type', new TypeValidationRule($validator)); parent::__construct($schema); }