GraphQL\Tests\Executor\ExecutorTest::testMergesParallelFragments PHP Method

testMergesParallelFragments() public method

    public function testMergesParallelFragments()
    {
        $ast = Parser::parse('
      { a, ...FragOne, ...FragTwo }

      fragment FragOne on Type {
        b
        deep { b, deeper: deep { b } }
      }

      fragment FragTwo on Type {
        c
        deep { c, deeper: deep { c } }
      }
        ');
        $Type = new ObjectType(['name' => 'Type', 'fields' => function () use(&$Type) {
            return ['a' => ['type' => Type::string(), 'resolve' => function () {
                return 'Apple';
            }], 'b' => ['type' => Type::string(), 'resolve' => function () {
                return 'Banana';
            }], 'c' => ['type' => Type::string(), 'resolve' => function () {
                return 'Cherry';
            }], 'deep' => ['type' => $Type, 'resolve' => function () {
                return [];
            }]];
        }]);
        $schema = new Schema(['query' => $Type]);
        $expected = ['data' => ['a' => 'Apple', 'b' => 'Banana', 'c' => 'Cherry', 'deep' => ['b' => 'Banana', 'c' => 'Cherry', 'deeper' => ['b' => 'Banana', 'c' => 'Cherry']]]];
        $this->assertEquals($expected, Executor::execute($schema, $ast)->toArray());
    }