File tree Expand file tree Collapse file tree
modules/graphql_core/tests/src/Kernel Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Drupal \Tests \graphql_core \Kernel \Context ;
4+
5+ use Drupal \node \Entity \Node ;
6+ use Drupal \Tests \graphql_core \Kernel \GraphQLContentTestBase ;
7+
8+ /**
9+ * Test full stack retrieval of a node context.
10+ */
11+ class NodeContextTest extends GraphQLContentTestBase {
12+
13+ /**
14+ * Regression test for unhandled logic exceptions.
15+ *
16+ * Leaking cache metadata.
17+ */
18+ public function testNodeContext () {
19+ $ nodeId = Node::create ([
20+ 'title ' => 'Test ' ,
21+ 'type ' => 'test ' ,
22+ ])->save ();
23+
24+ $ query = <<<GQL
25+ query ( \$path: String!) {
26+ route(path: \$path) {
27+ ... on InternalUrl {
28+ nodeContext {
29+ entityLabel
30+ }
31+ }
32+ }
33+ }
34+ GQL ;
35+
36+ $ this ->query ($ query , ['path ' => '/node/ ' . $ nodeId ]);
37+ }
38+
39+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Drupal \Tests \graphql_core \Kernel \Context ;
4+
5+ use Drupal \node \Entity \Node ;
6+ use Drupal \Tests \graphql_core \Kernel \GraphQLContentTestBase ;
7+
8+ /**
9+ * Fetch node revisions.
10+ */
11+ class EntityRevisionsTest extends GraphQLContentTestBase {
12+
13+ /**
14+ * Regression test for unhandled logic exceptions.
15+ *
16+ * Leaking cache metadata.
17+ */
18+ public function testNodeContext () {
19+ $ node = Node::create ([
20+ 'title ' => 'Test ' ,
21+ 'type ' => 'test ' ,
22+ ]);
23+
24+ $ nodeId = $ node ->save ();
25+ $ draft = $ this ->getNewDraft ($ node );
26+ $ draft ->save ();
27+
28+
29+ $ query = <<<GQL
30+ query ( \$path: String!) {
31+ route(path: \$path) {
32+ ... on EntityCanonicalUrl {
33+ entity {
34+ ... on EntityRevisionable {
35+ entityRevisions {
36+ count
37+ }
38+ }
39+ }
40+ }
41+ }
42+ }
43+ GQL ;
44+
45+ $ this ->query ($ query , ['path ' => '/node/ ' . $ nodeId ]);
46+ }
47+
48+ }
You can’t perform that action at this time.
0 commit comments