getContainer() public method

public getContainer ( ) : Youshido\GraphQL\Execution\Container\ContainerInterface
return Youshido\GraphQL\Execution\Container\ContainerInterface
Ejemplo n.º 1
0
 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());
 }