NodeContextTest.php in GraphQL 8.3        
                          
                  
                        
  
  
  
  
  
File
  modules/graphql_core/tests/src/Kernel/Context/NodeContextTest.php
  
    View source  
  <?php
namespace Drupal\Tests\graphql_core\Kernel\Context;
use Drupal\node\Entity\Node;
use Drupal\Tests\graphql_core\Kernel\GraphQLContentTestBase;
class NodeContextTest extends GraphQLContentTestBase {
  
  public function testNodeContext() {
    $nodeId = Node::create([
      'title' => 'Test',
      'type' => 'test',
    ])
      ->save();
    $query = <<<GQL
query (\$path: String!) {
  route(path: \$path) {
    ... on InternalUrl {
      nodeContext {
        entityLabel
      }
    }
  }
}
GQL;
    $this
      ->query($query, [
      'path' => '/node/' . $nodeId,
    ]);
  }
}