Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix overriding directives #245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
Loading
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Added test
  • Loading branch information
leoloso committed Apr 12, 2020
commit 437eb79ca5d6247a5ef51e6bd350d557f1785dbc
58 changes: 58 additions & 0 deletions 58 tests/Issues/Issue242/Issue242Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace Youshido\Tests\Issue194;

use PHPUnit\Framework\TestCase;
use Youshido\GraphQL\Parser\Parser;
use Youshido\GraphQL\Parser\Location;
use Youshido\GraphQL\Parser\Ast\Field;
use Youshido\GraphQL\Parser\Ast\Query;
use Youshido\GraphQL\Parser\Ast\Argument;
use Youshido\GraphQL\Parser\Ast\Directive;
use Youshido\GraphQL\Parser\Ast\ArgumentValue\Literal;

class Issue242Test extends TestCase
{
public function testDoNotOverrideFirstLevelQueryDirectives()
{
/**
* Without the patch, the operation query will override the first level
* query directives.
* In this case, directive `@include(if:false)` would be lost
* Please notice: the bug happens only when adding "query" at the beginning:
* query { ... }
* So this query had no issue:
* $payload = '{ user @include(if:false) { name } }';
*/
$payload = 'query { user @include(if:false) { name } }';
$parser = new Parser();
$data = $parser->parse($payload);
$this->assertEquals([
'queries' => [
new Query(
'user',
null,
[],
[
new Field('name', null, [], [], new Location(1, 35)),
],
[
new Directive(
'include',
[
new Argument('if', new Literal(false, new Location(1, 26)), new Location(1, 23)),
],
new Location(1, 15)
),
],
new Location(1, 9)
)
],
'mutations' => [],
'fragments' => [],
'fragmentReferences' => [],
'variables' => [],
'variableReferences' => [],
], $data);
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.