getSchema() public method

public getSchema ( ) : AbstractSchema
return Youshido\GraphQL\Schema\AbstractSchema
Ejemplo n.º 1
0
 protected function resolveQuery(AstQuery $query)
 {
     $schema = $this->executionContext->getSchema();
     $type = $query instanceof AstMutation ? $schema->getMutationType() : $schema->getQueryType();
     $field = new Field(['name' => $query instanceof AstMutation ? 'mutation' : 'query', 'type' => $type]);
     if (self::TYPE_NAME_QUERY == $query->getName()) {
         return [$this->getAlias($query) => $type->getName()];
     }
     $this->resolveValidator->assetTypeHasField($type, $query);
     $value = $this->resolveField($field, $query);
     return [$this->getAlias($query) => $value];
 }
Ejemplo n.º 2
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());
 }