Skip to content

Commit 44a0bee

Browse files
committed
Reviewed Type tests
1 parent b76e681 commit 44a0bee

16 files changed

+32
-184
lines changed

docs/tips.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ Create a new hydrator strategy
5151
}
5252
}
5353
54+
Add the type and hydrator strategy to the field:
55+
5456
.. code-block:: php
5557
5658
use ApiSkeletons\Doctrine\ORM\GraphQL\Attribute as GraphQL;

docs/types.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ input type.
115115
Custom Types
116116
============
117117

118-
If your schema has a ``timestamp`` type, that data type is not suppored
118+
If your schema has a ``timestamp`` type, that data type is not supported
119119
by this library. But adding the type is just a matter of creating a
120120
new Timestamp type extending ``GraphQL\Type\Definition\ScalarType`` then adding
121121
the type to the type container.
@@ -125,6 +125,7 @@ the type to the type container.
125125
$driver->get(TypeContainer::class)
126126
->set('timestamp', fn() => new Timestamp());
127127
128+
See also `Serve a CSV Field as a GraphQL Array <tips.html#serve-a-csv-field-as-a-graphql-array>`_.
128129

129130
.. role:: raw-html(raw)
130131
:format: html

test/Feature/Type/BetweenTest.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,7 @@ public function testTwoFilterSetsEachWithBetweenButDifferentOtherwiseFetchesBetw
2323
'query' => new ObjectType([
2424
'name' => 'query',
2525
'fields' => [
26-
'artist' => [
27-
'type' => $driver->type(TypeTest::class),
28-
'args' => [
29-
'filter' => $driver->filter(TypeTest::class),
30-
],
31-
'resolve' => $driver->resolve(TypeTest::class),
32-
],
26+
'typetest' => $driver->completeConnection(TypeTest::class),
3327
],
3428
]),
3529
]);

test/Feature/Type/BlobTest.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,7 @@ public function testBlobQuery(): void
9494
'query' => new ObjectType([
9595
'name' => 'query',
9696
'fields' => [
97-
'typetest' => [
98-
'type' => $driver->connection(TypeTest::class),
99-
'args' => [
100-
'filter' => $driver->filter(TypeTest::class),
101-
],
102-
'resolve' => $driver->resolve(TypeTest::class),
103-
],
97+
'typetest' => $driver->completeConnection(TypeTest::class),
10498
],
10599
]),
106100
]);

test/Feature/Type/CustomTypeTest.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,7 @@ public function testCustomFieldType(): void
2929
'query' => new ObjectType([
3030
'name' => 'query',
3131
'fields' => [
32-
'typeTest' => [
33-
'type' => $driver->connection(TypeTest::class),
34-
'args' => [
35-
'filter' => $driver->filter(TypeTest::class),
36-
],
37-
'resolve' => $driver->resolve(TypeTest::class),
38-
],
32+
'typeTest' => $driver->completeConnection(TypeTest::class),
3933
],
4034
]),
4135
]);
@@ -62,17 +56,17 @@ public function testCustomFieldTypeArray(): void
6256
'query' => new ObjectType([
6357
'name' => 'query',
6458
'fields' => [
65-
'typeTest' => $driver->completeConnection(TypeTest::class),
59+
'typetest' => $driver->completeConnection(TypeTest::class),
6660
],
6761
]),
6862
]);
6963

70-
$query = '{ typeTest { edges { node { testText } } } }';
64+
$query = '{ typetest { edges { node { testText } } } }';
7165
$result = GraphQL::executeQuery($schema, $query);
7266

7367
$data = $result->toArray()['data'];
7468

75-
$this->assertIsArray($data['typeTest']['edges'][0]['node']['testText']);
76-
$this->assertCount(3, $data['typeTest']['edges'][0]['node']['testText']);
69+
$this->assertIsArray($data['typetest']['edges'][0]['node']['testText']);
70+
$this->assertCount(3, $data['typetest']['edges'][0]['node']['testText']);
7771
}
7872
}

test/Feature/Type/DateImmutableTest.php

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,7 @@ public function testBetween(): void
6767
'query' => new ObjectType([
6868
'name' => 'query',
6969
'fields' => [
70-
'typetest' => [
71-
'type' => $driver->connection(TypeTest::class),
72-
'args' => [
73-
'filter' => $driver->filter(TypeTest::class),
74-
],
75-
'resolve' => $driver->resolve(TypeTest::class),
76-
],
70+
'typetest' => $driver->completeConnection(TypeTest::class),
7771
],
7872
]),
7973
]);
@@ -120,13 +114,7 @@ public function testBetweenLiteral(): void
120114
'query' => new ObjectType([
121115
'name' => 'query',
122116
'fields' => [
123-
'typetest' => [
124-
'type' => $driver->connection(TypeTest::class),
125-
'args' => [
126-
'filter' => $driver->filter(TypeTest::class),
127-
],
128-
'resolve' => $driver->resolve(TypeTest::class),
129-
],
117+
'typetest' => $driver->completeConnection(TypeTest::class),
130118
],
131119
]),
132120
]);
@@ -165,13 +153,7 @@ public function testInvalidLiteralValue(): void
165153
'query' => new ObjectType([
166154
'name' => 'query',
167155
'fields' => [
168-
'typetest' => [
169-
'type' => $driver->connection(TypeTest::class),
170-
'args' => [
171-
'filter' => $driver->filter(TypeTest::class),
172-
],
173-
'resolve' => $driver->resolve(TypeTest::class),
174-
],
156+
'typetest' => $driver->completeConnection(TypeTest::class),
175157
],
176158
]),
177159
]);

test/Feature/Type/DateTest.php

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,7 @@ public function testBetween(): void
6868
'query' => new ObjectType([
6969
'name' => 'query',
7070
'fields' => [
71-
'typetest' => [
72-
'type' => $driver->connection(TypeTest::class),
73-
'args' => [
74-
'filter' => $driver->filter(TypeTest::class),
75-
],
76-
'resolve' => $driver->resolve(TypeTest::class),
77-
],
71+
'typetest' => $driver->completeConnection(TypeTest::class),
7872
],
7973
]),
8074
]);
@@ -120,13 +114,7 @@ public function testBetweenLiteral(): void
120114
'query' => new ObjectType([
121115
'name' => 'query',
122116
'fields' => [
123-
'typetest' => [
124-
'type' => $driver->connection(TypeTest::class),
125-
'args' => [
126-
'filter' => $driver->filter(TypeTest::class),
127-
],
128-
'resolve' => $driver->resolve(TypeTest::class),
129-
],
117+
'typetest' => $driver->completeConnection(TypeTest::class),
130118
],
131119
]),
132120
]);
@@ -165,13 +153,7 @@ public function testInvalidLiteralValue(): void
165153
'query' => new ObjectType([
166154
'name' => 'query',
167155
'fields' => [
168-
'typetest' => [
169-
'type' => $driver->connection(TypeTest::class),
170-
'args' => [
171-
'filter' => $driver->filter(TypeTest::class),
172-
],
173-
'resolve' => $driver->resolve(TypeTest::class),
174-
],
156+
'typetest' => $driver->completeConnection(TypeTest::class),
175157
],
176158
]),
177159
]);

test/Feature/Type/DateTimeImmutableTest.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,7 @@ public function testBetween(): void
6262
'query' => new ObjectType([
6363
'name' => 'query',
6464
'fields' => [
65-
'typetest' => [
66-
'type' => $driver->connection(TypeTest::class),
67-
'args' => [
68-
'filter' => $driver->filter(TypeTest::class),
69-
],
70-
'resolve' => $driver->resolve(TypeTest::class),
71-
],
65+
'typetest' => $driver->completeConnection(TypeTest::class),
7266
],
7367
]),
7468
]);

test/Feature/Type/DateTimeTZImmutableTest.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,7 @@ public function testBetween(): void
6262
'query' => new ObjectType([
6363
'name' => 'query',
6464
'fields' => [
65-
'typetest' => [
66-
'type' => $driver->connection(TypeTest::class),
67-
'args' => [
68-
'filter' => $driver->filter(TypeTest::class),
69-
],
70-
'resolve' => $driver->resolve(TypeTest::class),
71-
],
65+
'typetest' => $driver->completeConnection(TypeTest::class),
7266
],
7367
]),
7468
]);

test/Feature/Type/DateTimeTZTest.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,7 @@ public function testBetween(): void
6060
'query' => new ObjectType([
6161
'name' => 'query',
6262
'fields' => [
63-
'typetest' => [
64-
'type' => $driver->connection(TypeTest::class),
65-
'args' => [
66-
'filter' => $driver->filter(TypeTest::class),
67-
],
68-
'resolve' => $driver->resolve(TypeTest::class),
69-
],
63+
'typetest' => $driver->completeConnection(TypeTest::class),
7064
],
7165
]),
7266
]);
@@ -78,8 +72,5 @@ public function testBetween(): void
7872
$data = $result->toArray()['data'];
7973

8074
$this->assertTrue(true);
81-
82-
// $this->assertEquals(1, count($data['typetest']['edges']));
83-
// $this->assertEquals(1, $data['typetest']['edges'][0]['node']['id']);
8475
}
8576
}

0 commit comments

Comments
 (0)