Skip to content

Commit

Permalink
psr
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaume leclercq committed Feb 27, 2017
1 parent d48a13f commit afd315a
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 7 deletions.
1 change: 1 addition & 0 deletions error.html

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions src/AppBundle/GraphQL/Mutation/Band/AddBandField.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
use Youshido\GraphQL\Config\Field\FieldConfig;
use Youshido\GraphQL\Execution\ResolveInfo;
use Youshido\GraphQL\Type\AbstractType;
use Youshido\GraphQL\Type\ListType\ListType;
use Youshido\GraphQL\Type\NonNullType;
use Youshido\GraphQL\Type\Object\AbstractObjectType;
use Youshido\GraphQL\Type\Scalar\StringType;
use Youshido\GraphQLBundle\Field\AbstractContainerAwareField;

class AddBandField extends AbstractContainerAwareField
Expand Down
4 changes: 1 addition & 3 deletions src/AppBundle/GraphQL/Mutation/Style/AddStyleField.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
use Youshido\GraphQL\Config\Field\FieldConfig;
use Youshido\GraphQL\Execution\ResolveInfo;
use Youshido\GraphQL\Type\AbstractType;
use Youshido\GraphQL\Type\ListType\ListType;
use Youshido\GraphQL\Type\NonNullType;
use Youshido\GraphQL\Type\Object\AbstractObjectType;
use Youshido\GraphQL\Type\Scalar\StringType;
use Youshido\GraphQLBundle\Field\AbstractContainerAwareField;

class AddStyleField extends AbstractContainerAwareField
Expand All @@ -21,7 +19,7 @@ public function build(FieldConfig $config)
$config->addArguments([
'style' => new NonNullType(new StyleTypeInput()),
]);
$config->setDescription("Add new Style");
$config->setDescription('Add new Style');
}

public function resolve($value, array $args, ResolveInfo $info)
Expand Down
39 changes: 39 additions & 0 deletions src/AppBundle/GraphQL/Query/Band/BandsFieldByStyle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace AppBundle\GraphQL\Query\Band;

use AppBundle\Entity\Band;
use AppBundle\GraphQL\Type\BandType;
use Youshido\GraphQL\Execution\ResolveInfo;
use Youshido\GraphQL\Type\AbstractType;
use Youshido\GraphQL\Type\ListType\ListType;
use Youshido\GraphQL\Type\Object\AbstractObjectType;
use Youshido\GraphQL\Type\Scalar\StringType;
use Youshido\GraphQLBundle\Field\AbstractContainerAwareField;
use Youshido\GraphQL\Config\Field\FieldConfig;

class BandsFieldByStyle extends AbstractContainerAwareField
{
public function build(FieldConfig $config)
{
$config->addArguments([
'style_name' => new StringType(),
]);
}

public function resolve($value, array $args, ResolveInfo $info)
{
$em = $this->container->get('doctrine')->getManager();
$repository = $em->getRepository(Band::class);

return $repository->findByStyleName($args['style_name']);
}

/**
* @return AbstractObjectType|AbstractType
*/
public function getType()
{
return new ListType(new BandType());
}
}
2 changes: 1 addition & 1 deletion src/AppBundle/GraphQL/Type/BandTypeInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function build($config)
{
$config->addFields([
'name' => new StringType(),
'style' => new IdType()
'style' => new IdType(),
]);
}
}
2 changes: 1 addition & 1 deletion src/AppBundle/GraphQL/Type/StyleTypeInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class StyleTypeInput extends AbstractInputObjectType
public function build($config)
{
$config->addFields([
'name' => new StringType()
'name' => new StringType(),
]);
}
}
1 change: 1 addition & 0 deletions src/AppBundle/Repository/BandRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class BandRepository extends \Doctrine\ORM\EntityRepository
{
/**
* @param $styleName
*
* @return array
*/
public function findByStyleName($styleName)
Expand Down

0 comments on commit afd315a

Please sign in to comment.