Skip to content

Commit

Permalink
Fixed some bugs with code maker
Browse files Browse the repository at this point in the history
  • Loading branch information
Maksym Churkyn committed Sep 17, 2018
1 parent 9ef60a4 commit 1aa2d4c
Show file tree
Hide file tree
Showing 25 changed files with 36 additions and 13 deletions.
Empty file modified Argument/ArgumentTypeAbstract.php
100644 → 100755
Empty file.
Empty file modified DependencyInjection/Configuration.php
100644 → 100755
Empty file.
Empty file modified DependencyInjection/GarlicGraphQLExtension.php
100644 → 100755
Empty file.
Empty file modified Field/FieldAbstract.php
100644 → 100755
Empty file.
Empty file modified Field/FieldHelperAbstract.php
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion Maker/MakeGraphQLQuery.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ final class MakeGraphQLQuery extends AbstractMaker
* @param $schemaNamespace
* @param FileManager $fileManager
*/
public function __construct(ClassFinder $classFinder, string $schemaNamespace, FileManager $fileManager)
public function __construct(ClassFinder $classFinder, FileManager $fileManager, $schemaNamespace = '')
{
$this->classFinder = $classFinder;
$this->schemaNamespace = $schemaNamespace;
Expand Down
29 changes: 22 additions & 7 deletions Maker/MakeGraphQLSchema.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@
*/
final class MakeGraphQLSchema extends AbstractMaker
{
/** @var string */
private $rootDir;

/**
* MakeGraphQLSchema constructor.
* @param string $rootDir
*/
public function __construct(string $rootDir)
{
$this->rootDir = $rootDir;
}

/**
* Return command name
* @return string
Expand Down Expand Up @@ -50,14 +62,14 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
'namespace' => 'GraphQL\\Query',
'template' => 'Query.tpl.php',
'variables' => [
'queries' => []
'fields' => []
]
],
'MutationType' =>[
'namespace' => 'GraphQL\\Mutation',
'template' => 'Mutation.tpl.php',
'variables' => [
'mutations' => []
'fields' => []
]
],
'schema' =>[
Expand All @@ -67,11 +79,14 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
],
];

$generator->generateFile(
dirname(dirname(dirname(__FILE__))).'/config/packages/graphql.yaml',
dirname(dirname(__FILE__)) . '/Resources/skeleton/graphql.tpl.yaml',
[]
);
$configFile = dirname($this->rootDir).'/config/packages/graphql.yaml';
if(!is_file($configFile)) {
$generator->generateFile(
$configFile,
dirname(dirname(__FILE__)) . '/Resources/skeleton/graphql.tpl.yaml',
[]
);
}

foreach ($classes as $name => $class) {
$classNameDetails = $generator->createClassNameDetails(
Expand Down
Empty file modified Maker/MakeGraphQLType.php
100644 → 100755
Empty file.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ composer require garlic/graphql
### Initialize GraphQL schema(create schema, query and mutation fields)

```bash
bin/console maker:graphql:init
bin/console make:graphql:init
```

### Create graphql type (command able to get fields from existing Entity)

```bash
bin/console maker:graphql:type
bin/console make:graphql:type
```

The command suggest you to create full CRUD mutations and queries, just type "y" to do so.
Expand All @@ -40,7 +40,7 @@ App\Service\GraphQL\:
### Make your first graphql query or mutation
```bash
bin/console maker:graphql:query
bin/console make:graphql:query
```

Now you can review and update newly created files!
Expand Down
10 changes: 9 additions & 1 deletion Resources/config/services.yml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ services:
arguments:
- "%kernel.root_dir%"

# Add maker command for creating GraphQL schema
maker.graphql.make_schema:
class: Garlic\GraphQL\Maker\MakeGraphQLSchema
public: true
tags: ['maker.command']
arguments:
- "%kernel.root_dir%"

# Add maker command for creating GraphQL type
maker.graphql.make_type:
class: Garlic\GraphQL\Maker\MakeGraphQLType
Expand All @@ -38,5 +46,5 @@ services:
tags: ['maker.command']
arguments:
- "@class_finder"
- "@maker.file_manager"
- '%graphql.schema_class%'
- "@maker.file_manager"
Empty file modified Resources/skeleton/Mutation.tpl.php
100644 → 100755
Empty file.
Empty file modified Resources/skeleton/MutationResolver.tpl.php
100644 → 100755
Empty file.
Empty file modified Resources/skeleton/Query.tpl.php
100644 → 100755
Empty file.
Empty file modified Resources/skeleton/QueryResolver.tpl.php
100644 → 100755
Empty file.
Empty file modified Resources/skeleton/Resolver.tpl.php
100644 → 100755
Empty file.
Empty file modified Resources/skeleton/Schema.tpl.php
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion Resources/skeleton/Service.tpl.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace <?= $namespace ?>;

use Garlic\GraphQL\Service\AbstractCrudService;
use Garlic\GraphQL\Service\Abstracts\AbstractCrudService;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use <?= $entityFullName ?>;

Expand Down
Empty file modified Resources/skeleton/Type.tpl.php
100644 → 100755
Empty file.
Empty file modified Resources/skeleton/graphql.tpl.yaml
100644 → 100755
Empty file.
Empty file modified Service/Abstracts/AbstractCrudService.php
100644 → 100755
Empty file.
Empty file modified Service/Helper/ClassFinder.php
100644 → 100755
Empty file.
Empty file modified Type/Interfaces/BuilderInterface.php
100644 → 100755
Empty file.
Empty file modified Type/TypeAbstract.php
100644 → 100755
Empty file.
Empty file modified Type/TypeBuilder.php
100644 → 100755
Empty file.
Empty file modified Type/TypeHelper.php
100644 → 100755
Empty file.

0 comments on commit 1aa2d4c

Please sign in to comment.