示例#1
0
文件: Tools.php 项目: chupo22/bxtools
 static function getSelectByResolveInfo(ResolveInfo $info)
 {
     return array_map(function ($item) {
         /** @var Field|Query $item */
         return $item->getName();
     }, $info->getFieldASTList());
 }
示例#2
0
 public function resolve($value, array $args, ResolveInfo $info)
 {
     if ($value) {
         if ($value instanceof ODMImageableInterface || $value instanceof ORMImageableInterface || method_exists('getImage', $value)) {
             if ($image = $value->getImage()) {
                 return ['id' => $image instanceof EmbeddedImage ? $image->getReferenceId() : $image->getId(), 'url' => $info->getContainer()->get('api_images.path_resolver')->resolveWebPath($image), 'image' => $image];
             }
         }
     }
     return null;
 }
示例#3
0
 public function testMethods()
 {
     $fieldAst = new FieldAST('name', null, [], new Location(1, 1));
     $field = new Field(['name' => 'id', 'type' => new IntType()]);
     $returnType = new IntType();
     $executionContext = new ExecutionContext(new TestSchema());
     $info = new ResolveInfo($field, [$fieldAst], $executionContext);
     $this->assertEquals($field, $info->getField());
     $this->assertEquals([$fieldAst], $info->getFieldASTList());
     $this->assertEquals($returnType, $info->getReturnType());
     $this->assertEquals($executionContext, $info->getExecutionContext());
 }
示例#4
0
 public function resolve($value = null, array $args, ResolveInfo $info)
 {
     $schema = $info->getExecutionContext()->getSchema();
     $this->collectTypes($schema->getQueryType());
     $this->collectTypes($schema->getMutationType());
     foreach ($schema->getTypesList()->getTypes() as $type) {
         $this->collectTypes($type);
     }
     foreach ($this->types as $name => $info) {
         if ($name == $args['name']) {
             return $info;
         }
     }
     return null;
 }
示例#5
0
 public function resolve($value, array $args, ResolveInfo $info)
 {
     return $info->getExecutionContext()->getSchema();
 }
示例#6
0
 public function resolve($value, array $args, ResolveInfo $info)
 {
     $image = $info->getContainer()->get('api_images.provider')->getOne($args['id']);
     return ['id' => $image->getId(), 'url' => $info->getContainer()->get('api_images.path_resolver')->resolveWebPath($image), 'image' => $image];
 }
示例#7
0
 /**
  * @param null        $value
  * @param array       $args
  * @param ResolveInfo $info
  * @return mixed
  */
 public function resolve($value, array $args, ResolveInfo $info)
 {
     return $info->getReturnType()->getOne($args['id']);
 }
示例#8
0
 public function resolvePossibleTypes($value, $args, ResolveInfo $info)
 {
     /** @var $value AbstractObjectType */
     if ($value->getKind() == TypeMap::KIND_INTERFACE) {
         $this->collectTypes($info->getExecutionContext()->getSchema()->getQueryType());
         $possibleTypes = [];
         foreach ($this->types as $type) {
             /** @var $type AbstractObjectType */
             if ($type->getKind() == TypeMap::KIND_OBJECT) {
                 $interfaces = $type->getConfig()->getInterfaces();
                 if ($interfaces) {
                     foreach ($interfaces as $interface) {
                         if ($interface->getName() == $value->getName()) {
                             $possibleTypes[] = $type;
                         }
                     }
                 }
             }
         }
         return $possibleTypes;
     } elseif ($value->getKind() == TypeMap::KIND_UNION) {
         /** @var $value AbstractUnionType */
         return $value->getTypes();
     }
     return null;
 }