Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ matrix:
fast_finish: true
include:
- php: 5.6
env: COMPOSER_UPDATE_FLAGS=--prefer-lowest SYMFONY_DEPRECATIONS_HELPER=disabled
env: COMPOSER_UPDATE_FLAGS=--prefer-lowest SYMFONY_DEPRECATIONS_HELPER=disabled GRAPHQLPHP_VERSION=^0.11.2
- php: 5.6
env: SYMFONY_VERSION=3.1.* SYMFONY_DEPRECATIONS_HELPER=disabled
env: SYMFONY_VERSION=3.1.* SYMFONY_DEPRECATIONS_HELPER=disabled GRAPHQLPHP_VERSION=0.12
- php: 7.0
env: SYMFONY_VERSION=3.2.* PHPUNIT_VERSION=^5.7.26
- php: 7.1
Expand Down
3 changes: 2 additions & 1 deletion Command/GraphQLDumpSchemaCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ private function createFile(InputInterface $input)
switch ($format) {
case 'json':
$request = [
'query' => Introspection::getIntrospectionQuery(false),
// TODO(mcg-web): remove silence deprecation notices after removing webonyx/graphql-php <= 0.11
'query' => @Introspection::getIntrospectionQuery(false),
'variables' => [],
'operationName' => null,
];
Expand Down
3 changes: 3 additions & 0 deletions Config/Parser/GraphQLParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ private function astValueNodeToConfig(ValueNode $valueNode)

private function cleanAstDescription($description)
{
if (property_exists($description, 'value')) {
$description = $description->value;
}
$description = trim($description);

return empty($description) ? null : $description;
Expand Down
2 changes: 1 addition & 1 deletion Definition/Type/CustomScalarType.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function parseValue($value)
/**
* {@inheritdoc}
*/
public function parseLiteral(/* GraphQL\Language\AST\ValueNode */ $valueNode)
public function parseLiteral(/* GraphQL\Language\AST\ValueNode */ $valueNode, array $variables = null)
{
return $this->call('parseLiteral', $valueNode);
}
Expand Down
4 changes: 1 addition & 3 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,7 @@ private function servicesSection()
->scalarNode('expression_language')
->defaultValue(self::NAME.'.expression_language.default')
->end()
->scalarNode('cache_expression_language_parser')
->defaultValue(self::NAME.'.cache_expression_language_parser.default')
->end()
->scalarNode('cache_expression_language_parser')->end()
->end()
->end();

Expand Down
11 changes: 0 additions & 11 deletions DependencyInjection/OverblogGraphQLExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@
use Overblog\GraphQLBundle\EventListener\DebugListener;
use Overblog\GraphQLBundle\EventListener\ErrorHandlerListener;
use Overblog\GraphQLBundle\EventListener\ErrorLoggerListener;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\ExpressionLanguage\ParserCache\ArrayParserCache;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\HttpKernel\Kernel;

Expand All @@ -33,7 +31,6 @@ public function load(array $configs, ContainerBuilder $container)
$config = $this->treatConfigs($configs, $container);

$this->setBatchingMethod($config, $container);
$this->setExpressionLanguageDefaultParser($container);
$this->setServicesAliases($config, $container);
$this->setSchemaBuilderArguments($config, $container);
$this->setSchemaArguments($config, $container);
Expand Down Expand Up @@ -124,14 +121,6 @@ private function setBatchingMethod(array $config, ContainerBuilder $container)
$container->setParameter($this->getAlias().'.batching_method', $config['batching_method']);
}

private function setExpressionLanguageDefaultParser(ContainerBuilder $container)
{
$class = version_compare(Kernel::VERSION, '3.2.0', '>=') ? ArrayAdapter::class : ArrayParserCache::class;
$definition = new Definition($class);
$definition->setPublic(false);
$container->setDefinition($this->getAlias().'.cache_expression_language_parser.default', $definition);
}

private function setDebugListener(array $config, ContainerBuilder $container)
{
if ($config['definitions']['show_debug_info']) {
Expand Down
2 changes: 1 addition & 1 deletion Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ services:
class: Overblog\GraphQLBundle\ExpressionLanguage\ExpressionLanguage
public: false
arguments:
- '@overblog_graphql.cache_expression_language_parser'
- '@?overblog_graphql.cache_expression_language_parser'

overblog_graphql.cache_compiler:
class: Overblog\GraphQLBundle\Generator\TypeGenerator
Expand Down
20 changes: 18 additions & 2 deletions Tests/Config/Parser/GraphQLParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ public function setUp()

public function testParse()
{
$fileName = __DIR__.'/fixtures/graphql/schema.graphql';
$fileName = sprintf(
__DIR__.'/fixtures/graphql/schema%s.graphql',
isset($_SERVER['GRAPHQLPHP_VERSION']) && '^0.11.2' === $_SERVER['GRAPHQLPHP_VERSION'] ? '-0.11' : ''
);
$expected = include __DIR__.'/fixtures/graphql/schema.php';

$this->assertContainerAddFileToResources($fileName);
$config = GraphQLParser::parse(new \SplFileInfo($fileName), $this->containerBuilder);
$this->assertEquals($expected, $config);
$this->assertEquals($expected, self::cleanConfig($config));
}

public function testParseEmptyFile()
Expand Down Expand Up @@ -65,4 +68,17 @@ private function assertContainerAddFileToResources($fileName)
->method('addResource')
->with($fileName);
}

private static function cleanConfig($config)
{
foreach ($config as $key => &$value) {
if (is_array($value)) {
$value = self::cleanConfig($value);
}
}

return array_filter($config, function ($item) {
return !is_array($item) || !empty($item);
});
}
}
54 changes: 54 additions & 0 deletions Tests/Config/Parser/fixtures/graphql/schema-0.11.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Root Query
type Query {
hero(
# Episode list to use to filter
episodes: [Episode!]! = [NEWHOPE, EMPIRE]
): Character
# search for a droid
droid(id: ID!): Droid
}

type Starship {
id: ID!
name: String!
length(unit: LengthUnit = METER): Float
}

enum Episode {
NEWHOPE
EMPIRE
JEDI
}

interface Character {
id: ID!
name: String!
friends: [Character]
appearsIn: [Episode]!
}

type Human implements Character {
id: ID!
name: String!
friends: [Character]
appearsIn: [Episode]!
starships: [Starship]
totalCredits: Int
}

type Droid implements Character {
id: ID!
name: String!
friends: [Character]
appearsIn: [Episode]!
primaryFunction: String
}

union SearchResult = Human | Droid | Starship

input ReviewInput {
stars: Int! = 5
commentary: String = null
}

scalar Year
6 changes: 3 additions & 3 deletions Tests/Config/Parser/fixtures/graphql/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Root Query
"""Root Query"""
type Query {
hero(
# Episode list to use to filter
"""Episode list to use to filter"""
episodes: [Episode!]! = [NEWHOPE, EMPIRE]
): Character
# search for a droid
"""search for a droid"""
droid(id: ID!): Droid
}

Expand Down
7 changes: 1 addition & 6 deletions Tests/Functional/App/Type/YearScalarType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use GraphQL\Error\Error;
use GraphQL\Language\AST\StringValueNode;
use GraphQL\Type\Definition\ScalarType;
use GraphQL\Utils;

class YearScalarType extends ScalarType
{
Expand All @@ -22,17 +21,13 @@ public function serialize($value)
*/
public function parseValue($value)
{
if (!is_string($value)) {
throw new Error(sprintf('Cannot represent following value as a valid year: %s.', Utils::printSafeJson($value)));
}

return (int) str_replace(' AC', '', $value);
}

/**
* {@inheritdoc}
*/
public function parseLiteral($valueNode)
public function parseLiteral($valueNode, array $variables = null)
{
if (!$valueNode instanceof StringValueNode) {
throw new Error('Query error: Can only parse strings got: '.$valueNode->kind, [$valueNode]);
Expand Down
2 changes: 2 additions & 0 deletions Tests/Functional/Command/GraphDumpSchemaCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ private function assertCommandExecution(array $input, $expectedFile, $actualFile
$actual = json_decode($actual, true);
$this->sortSchemaEntry($expected, 'types', 'name');
$this->sortSchemaEntry($actual, 'types', 'name');
} elseif ('graphql' === $format && isset($_SERVER['GRAPHQLPHP_VERSION']) && '^0.11.2' === $_SERVER['GRAPHQLPHP_VERSION']) {
$expected = preg_replace('@"""(.*)"""@', '# $1', $expected);
}

$this->assertEquals($expected, $actual);
Expand Down
36 changes: 18 additions & 18 deletions Tests/Functional/Command/fixtures/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Information about pagination in a connection.
"""Information about pagination in a connection."""
type PageInfo {
# When paginating forwards, are there more items?
"""When paginating forwards, are there more items?"""
hasNextPage: Boolean!

# When paginating backwards, are there more items?
"""When paginating backwards, are there more items?"""
hasPreviousPage: Boolean!

# When paginating backwards, the cursor to continue.
"""When paginating backwards, the cursor to continue."""
startCursor: String

# When paginating forwards, the cursor to continue.
"""When paginating forwards, the cursor to continue."""
endCursor: String
}

Expand All @@ -18,49 +18,49 @@ type Query {
}

type User {
# the user name
"""the user name"""
name: String
friends(after: String, first: Int, before: String, last: Int): friendConnection
friendsForward(after: String, first: Int): userConnection
friendsBackward(before: String, last: Int): userConnection
}

# A connection to a list of items.
"""A connection to a list of items."""
type friendConnection {
totalCount: Int

# Information to aid in pagination.
"""Information to aid in pagination."""
pageInfo: PageInfo!

# Information to aid in pagination.
"""Information to aid in pagination."""
edges: [friendEdge]
}

# An edge in a connection.
"""An edge in a connection."""
type friendEdge {
friendshipTime: String

# The item at the end of the edge.
"""The item at the end of the edge."""
node: User

# A cursor for use in pagination.
"""A cursor for use in pagination."""
cursor: String!
}

# A connection to a list of items.
"""A connection to a list of items."""
type userConnection {
# Information to aid in pagination.
"""Information to aid in pagination."""
pageInfo: PageInfo!

# Information to aid in pagination.
"""Information to aid in pagination."""
edges: [userEdge]
}

# An edge in a connection.
"""An edge in a connection."""
type userEdge {
# The item at the end of the edge.
"""The item at the end of the edge."""
node: User

# A cursor for use in pagination.
"""A cursor for use in pagination."""
cursor: String!
}
3 changes: 1 addition & 2 deletions Tests/Functional/Upload/UploadTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Overblog\GraphQLBundle\Tests\Functional\Security;
namespace Overblog\GraphQLBundle\Tests\Functional\Upload;

use GraphQL\Error\InvariantViolation;
use Overblog\GraphQLBundle\Tests\Functional\TestCase;
Expand Down Expand Up @@ -95,7 +95,6 @@ public function testOldUpload()
public function testSerializationIsUnsupported()
{
$this->expectException(InvariantViolation::class);
$this->expectExceptionMessage('Upload scalar serialization unsupported.');
$this->uploadRequest(
[
'operations' => [
Expand Down
2 changes: 1 addition & 1 deletion Upload/Type/GraphQLUploadType.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function serialize($value)
/**
* {@inheritdoc}
*/
public function parseLiteral($valueNode)
public function parseLiteral($valueNode, array $variables = null)
{
throw new InvariantViolation(sprintf('%s scalar literal unsupported.', $this->name));
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"symfony/framework-bundle": "^3.1 || ^4.0",
"symfony/options-resolver": "^3.1 || ^4.0",
"symfony/property-access": "^3.1 || ^4.0",
"webonyx/graphql-php": "^0.11.2"
"webonyx/graphql-php": "^0.11.2 || ^0.12.0"
},
"suggest": {
"nelmio/cors-bundle": "For more flexibility when using CORS prefight",
Expand Down