Skip to content

Commit b177a21

Browse files
committed
Merge branch '0.11'
2 parents 14b9754 + cf7f4fc commit b177a21

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+3227
-17
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
phpunit.xml
22
/build
33
/vendor
4+
/lib/*/vendor
45
/bin
56
composer.lock
67
composer.phar

.php_cs.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
$finder = PhpCsFixer\Finder::create()
44
->exclude('vendor')
55
->name('*.php')
6-
->in(__DIR__)
6+
->in([__DIR__.'/src', __DIR__.'/tests'])
77
;
88

99
return PhpCsFixer\Config::create()

composer.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,23 @@
1212
],
1313
"autoload": {
1414
"psr-4": {
15-
"Overblog\\GraphQLBundle\\": "src"
15+
"Overblog\\GraphQLBundle\\": "src/",
16+
"Overblog\\GraphQLGenerator\\": "lib/generator/src/"
1617
}
1718
},
1819
"autoload-dev": {
1920
"psr-4": {
20-
"Overblog\\GraphQLBundle\\Benchmarks\\": "benchmarks",
21-
"Overblog\\GraphQLBundle\\Tests\\": "tests"
22-
},
23-
"files": [
24-
"vendor/overblog/graphql-php-generator/tests/DateTimeType.php",
25-
"vendor/overblog/graphql-php-generator/tests/Resolver.php"
26-
]
21+
"Overblog\\GraphQLBundle\\Benchmarks\\": "benchmarks/",
22+
"Overblog\\GraphQLBundle\\Tests\\": "tests/",
23+
"Overblog\\GraphQLGenerator\\Tests\\": "lib/generator/tests/"
24+
}
2725
},
2826
"config" : {
2927
"bin-dir": "bin",
3028
"sort-packages": true
3129
},
3230
"require": {
3331
"php": ">=7.1",
34-
"overblog/graphql-php-generator": "^0.7.4",
3532
"psr/log": "^1.0",
3633
"symfony/config": "^3.4 || ^4.0",
3734
"symfony/dependency-injection": "^3.4 || ^4.0",
@@ -42,6 +39,9 @@
4239
"symfony/property-access": "^3.4 || ^4.0",
4340
"webonyx/graphql-php": "^0.12.0"
4441
},
42+
"replace": {
43+
"overblog/graphql-php-generator": "self.version"
44+
},
4545
"suggest": {
4646
"nelmio/cors-bundle": "For more flexibility when using CORS prefight",
4747
"overblog/graphiql-bundle": "If you want to use graphiQL.",
@@ -60,8 +60,6 @@
6060
"symfony/phpunit-bridge": "^3.4 || ^4.0",
6161
"symfony/process": "^3.4 || ^4.0",
6262
"symfony/security-bundle": "^3.4 || ^4.0",
63-
"symfony/templating": "^3.4 || ^4.0",
64-
"symfony/web-profiler-bundle": "^3.4 || ^4.0",
6563
"symfony/yaml": "^3.4 || ^4.0"
6664
},
6765
"extra": {
@@ -80,11 +78,13 @@
8078
"fix-cs": [
8179
"@install-cs",
8280
"@php php-cs-fixer.phar self-update",
83-
"@php php-cs-fixer.phar fix --diff -v --allow-risky=yes --ansi"
81+
"@php php-cs-fixer.phar fix --diff -v --allow-risky=yes --ansi",
82+
"@php php-cs-fixer.phar fix --config=lib/generator/.php_cs.dist --diff -v --allow-risky=yes --ansi"
8483
],
8584
"check-cs": [
8685
"@install-cs",
87-
"@php php-cs-fixer.phar fix --dry-run --diff -v --allow-risky=yes --ansi"
86+
"@php php-cs-fixer.phar fix --dry-run --diff -v --allow-risky=yes --ansi",
87+
"@php php-cs-fixer.phar fix --config=lib/generator/.php_cs.dist --dry-run --diff -v --allow-risky=yes --ansi"
8888
],
8989
"code-quality": [
9090
"rm composer.lock",

lib/generator/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/vendor/
2+
/bin/
3+
/composer.lock
4+
/composer.phar
5+
/phpunit.xml
6+
/.php_cs
7+
/.php_cs.cache

lib/generator/.php_cs.dist

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the OverblogGraphQLPhpGenerator package.
5+
*
6+
* (c) Overblog <http://github.com/overblog/>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
$header = <<<EOF
13+
This file is part of the OverblogGraphQLPhpGenerator package.
14+
15+
(c) Overblog <http://github.com/overblog/>
16+
17+
For the full copyright and license information, please view the LICENSE
18+
file that was distributed with this source code.
19+
EOF;
20+
21+
$finder = PhpCsFixer\Finder::create()
22+
->exclude('vendor')
23+
->name('*.php')
24+
->in([__DIR__.'/src', __DIR__.'/tests'])
25+
;
26+
27+
return PhpCsFixer\Config::create()
28+
->setUsingCache(true)
29+
->setFinder($finder)
30+
->setRules([
31+
'@PSR2' => true,
32+
'single_blank_line_before_namespace' => true,
33+
'ordered_imports' => true,
34+
'concat_space' => ['spacing' => 'none'],
35+
'phpdoc_no_alias_tag' => ['type' => 'var'],
36+
'no_mixed_echo_print' => ['use' => 'echo'],
37+
'binary_operator_spaces' => ['align_double_arrow' => false, 'align_equals' => false],
38+
'general_phpdoc_annotation_remove' => ['author', 'category', 'copyright', 'created', 'license', 'package', 'since', 'subpackage', 'version'],
39+
'native_function_invocation' => true,
40+
'fully_qualified_strict_types' => true,
41+
'native_constant_invocation' => true,
42+
'header_comment' => ['header' => $header],
43+
])
44+
;

lib/generator/.scrutinizer.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
tools:
2+
external_code_coverage:
3+
timeout: 1200
4+
build:
5+
tests:
6+
override:
7+
- true

lib/generator/.travis.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
dist: trusty
2+
3+
language: php
4+
5+
git:
6+
depth: 50
7+
8+
branches:
9+
only:
10+
- master
11+
- /^\d+\.\d+$/
12+
13+
cache:
14+
directories:
15+
- $HOME/.composer/cache
16+
- $HOME/.php_cs.cache
17+
18+
before_install:
19+
- if [ "${STABILITY}" != "" ]; then perl -pi -e 's/^}$/,"minimum-stability":"'"${STABILITY}"'"}/' composer.json; fi;
20+
- if [ "${PHPUNIT_VERSION}" != "" ]; then composer req "phpunit/phpunit:${PHPUNIT_VERSION}" --dev --no-update; fi;
21+
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available"
22+
- composer selfupdate
23+
- if [ $GRAPHQLPHP_VERSION ]; then composer require "webonyx/graphql-php:${GRAPHQLPHP_VERSION}" --dev --no-update; fi;
24+
25+
install: travis_retry composer update --prefer-source --no-interaction --optimize-autoloader ${COMPOSER_UPDATE_FLAGS}
26+
27+
script: bin/phpunit --color=always -v --debug
28+
29+
jobs:
30+
include:
31+
- stage: Test
32+
php: 5.6
33+
- php: 7.0
34+
- php: 7.1
35+
- php: 7.1
36+
env: COMPOSER_UPDATE_FLAGS=--prefer-lowest
37+
- php: 7.2
38+
- php: 7.3
39+
- php: nightly
40+
env: COMPOSER_UPDATE_FLAGS=--ignore-platform-reqs
41+
42+
- stage: Code Quality
43+
php: 7.2
44+
env: COVERAGE
45+
before_script:
46+
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{.disabled,}
47+
- if [[ ! $(php -m | grep -si xdebug) ]]; then echo "xdebug required for coverage"; exit 1; fi
48+
script: bin/phpunit --color=always -v --debug -d xdebug.max_nesting_level=1000 --coverage-clover=build/logs/clover.xml
49+
after_script:
50+
- wget https://scrutinizer-ci.com/ocular.phar && travis_retry php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml
51+
52+
- stage: Code Quality
53+
php: 7.2
54+
env: CODING_STANDARDS
55+
script: bin/php-cs-fixer fix --dry-run --diff -v --allow-risky=yes --ansi
56+
57+
allow_failures:
58+
- php: nightly
59+
env: COMPOSER_UPDATE_FLAGS=--ignore-platform-reqs

lib/generator/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) Overblog
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

lib/generator/README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
OverblogGraphQLPhpGenerator
2+
===========================
3+
4+
5+
GraphQL PHP types generator...
6+
7+
[![Code Coverage](https://scrutinizer-ci.com/g/overblog/GraphQLPhpGenerator/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/overblog/GraphQLPhpGenerator/?branch=master)
8+
[![Build Status](https://travis-ci.org/overblog/GraphQLPhpGenerator.svg?branch=master)](https://travis-ci.org/overblog/GraphQLPhpGenerator)
9+
10+
Requirements
11+
------------
12+
PHP >= 5.4
13+
14+
Installation
15+
------------
16+
17+
```bash
18+
composer require overblog/graphql-php-generator
19+
```
20+
21+
Usage
22+
-----
23+
24+
```php
25+
<?php
26+
$loader = require __DIR__.'/vendor/autoload.php';
27+
28+
use GraphQL\Schema;
29+
use Overblog\GraphQLGenerator\Generator\TypeGenerator;
30+
use Symfony\Component\ExpressionLanguage\Expression;
31+
32+
$configs = [
33+
'Character' => [
34+
'type' => 'interface',
35+
'config' => [
36+
'description' => new Expression('\'A character\' ~ \' in the Star Wars Trilogy\''),
37+
'fields' => [
38+
'id' => ['type' => 'String!', 'description' => 'The id of the character.'],
39+
'name' => ['type' => 'String', 'description' => 'The name of the character.'],
40+
'friends' => ['type' => '[Character]', 'description' => 'The friends of the character.'],
41+
'appearsIn' => ['type' => '[Episode]', 'description' => 'Which movies they appear in.'],
42+
],
43+
'resolveType' => 'Overblog\\GraphQLGenerator\\Tests\\Resolver::resolveType',
44+
],
45+
],
46+
/*...*/
47+
'Query' => [
48+
'type' => 'object',
49+
'config' => [
50+
'description' => 'A humanoid creature in the Star Wars universe or a faction in the Star Wars saga.',
51+
'fields' => [
52+
'hero' => [
53+
'type' => 'Character',
54+
'args' => [
55+
'episode' => [
56+
'type' => 'Episode',
57+
'description' => 'If omitted, returns the hero of the whole saga. If provided, returns the hero of that particular episode.',
58+
],
59+
],
60+
'resolve' => ['Overblog\\GraphQLGenerator\\Tests\\Resolver', 'getHero'],
61+
],
62+
],
63+
],
64+
/*...*/
65+
],
66+
];
67+
68+
$typeGenerator = new TypeGenerator('\\My\\Schema\\NP');
69+
$classesMap = $typeGenerator->generateClasses($configs, __DIR__ . '/cache/types');
70+
71+
$loader->addClassMap($classesMap);
72+
73+
$schema = new Schema(\My\Schema\NP\QueryType::getInstance());
74+
```

lib/generator/composer.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "overblog/graphql-php-generator",
3+
"type": "library",
4+
"description": "GraphQL types generator",
5+
"keywords": ["GraphQL", "type", "generator"],
6+
"license": "MIT",
7+
"authors": [
8+
{
9+
"name": "Overblog",
10+
"homepage": "http://www.over-blog.com"
11+
}
12+
],
13+
"config" : {
14+
"sort-packages": true,
15+
"bin-dir": "bin"
16+
},
17+
"require": {
18+
"php": ">=5.6",
19+
"webonyx/graphql-php": "^0.11.2|^0.12.0"
20+
},
21+
"require-dev": {
22+
"friendsofphp/php-cs-fixer": "^2.14",
23+
"phpunit/phpunit": "^5.7.26 || ^6.0 || ^7.2",
24+
"symfony/expression-language": "^3.4",
25+
"symfony/filesystem": "^3.4",
26+
"symfony/process": "^3.4",
27+
"symfony/yaml": "^3.4"
28+
},
29+
"autoload": {
30+
"psr-4": {
31+
"Overblog\\GraphQLGenerator\\": "src/"
32+
}
33+
},
34+
"autoload-dev": {
35+
"psr-4": {
36+
"Overblog\\GraphQLGenerator\\Tests\\": "tests/"
37+
}
38+
}
39+
}

lib/generator/phpunit.xml.dist

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<phpunit backupGlobals="false"
4+
backupStaticAttributes="false"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnFailure="false"
11+
syntaxCheck="false"
12+
bootstrap="vendor/autoload.php"
13+
>
14+
<testsuites>
15+
<testsuite name="overblog/graphql-php-generator Test Suite">
16+
<directory>./tests/</directory>
17+
</testsuite>
18+
</testsuites>
19+
20+
<filter>
21+
<whitelist>
22+
<directory>./</directory>
23+
<exclude>
24+
<directory>./tests</directory>
25+
<directory>./src/Overblog/Resources</directory>
26+
<directory>./vendor</directory>
27+
</exclude>
28+
</whitelist>
29+
</filter>
30+
31+
<php>
32+
<ini name="error_reporting" value="E_ALL"/>
33+
</php>
34+
35+
</phpunit>

0 commit comments

Comments
 (0)