Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions docs/tips.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ Create a new hydrator strategy
}
}

Add the type and hydrator strategy to the field:

.. code-block:: php

use ApiSkeletons\Doctrine\ORM\GraphQL\Attribute as GraphQL;
Expand All @@ -62,6 +64,7 @@ Create a new hydrator strategy
Add the new type and hydrator strategy to the Driver:

.. code-block:: php

use ApiSkeletons\Doctrine\ORM\GraphQL\Hydrator\HydratorContainer;
use ApiSkeletons\Doctrine\ORM\GraphQL\Type\TypeContainer;
use App\GraphQL\Hydrator\Strategy\CsvString;
Expand Down
3 changes: 2 additions & 1 deletion docs/types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ input type.
Custom Types
============

If your schema has a ``timestamp`` type, that data type is not suppored
If your schema has a ``timestamp`` type, that data type is not supported
by this library. But adding the type is just a matter of creating a
new Timestamp type extending ``GraphQL\Type\Definition\ScalarType`` then adding
the type to the type container.
Expand All @@ -125,6 +125,7 @@ the type to the type container.
$driver->get(TypeContainer::class)
->set('timestamp', fn() => new Timestamp());

See also `Serve a CSV Field as a GraphQL Array <tips.html#serve-a-csv-field-as-a-graphql-array>`_.

.. role:: raw-html(raw)
:format: html
Expand Down
8 changes: 1 addition & 7 deletions test/Feature/Type/BetweenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@ public function testTwoFilterSetsEachWithBetweenButDifferentOtherwiseFetchesBetw
'query' => new ObjectType([
'name' => 'query',
'fields' => [
'artist' => [
'type' => $driver->type(TypeTest::class),
'args' => [
'filter' => $driver->filter(TypeTest::class),
],
'resolve' => $driver->resolve(TypeTest::class),
],
'typetest' => $driver->completeConnection(TypeTest::class),
],
]),
]);
Expand Down
8 changes: 1 addition & 7 deletions test/Feature/Type/BlobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,7 @@ public function testBlobQuery(): void
'query' => new ObjectType([
'name' => 'query',
'fields' => [
'typetest' => [
'type' => $driver->connection(TypeTest::class),
'args' => [
'filter' => $driver->filter(TypeTest::class),
],
'resolve' => $driver->resolve(TypeTest::class),
],
'typetest' => $driver->completeConnection(TypeTest::class),
],
]),
]);
Expand Down
16 changes: 5 additions & 11 deletions test/Feature/Type/CustomTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,7 @@ public function testCustomFieldType(): void
'query' => new ObjectType([
'name' => 'query',
'fields' => [
'typeTest' => [
'type' => $driver->connection(TypeTest::class),
'args' => [
'filter' => $driver->filter(TypeTest::class),
],
'resolve' => $driver->resolve(TypeTest::class),
],
'typeTest' => $driver->completeConnection(TypeTest::class),
],
]),
]);
Expand All @@ -62,17 +56,17 @@ public function testCustomFieldTypeArray(): void
'query' => new ObjectType([
'name' => 'query',
'fields' => [
'typeTest' => $driver->completeConnection(TypeTest::class),
'typetest' => $driver->completeConnection(TypeTest::class),
],
]),
]);

$query = '{ typeTest { edges { node { testText } } } }';
$query = '{ typetest { edges { node { testText } } } }';
$result = GraphQL::executeQuery($schema, $query);

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

$this->assertIsArray($data['typeTest']['edges'][0]['node']['testText']);
$this->assertCount(3, $data['typeTest']['edges'][0]['node']['testText']);
$this->assertIsArray($data['typetest']['edges'][0]['node']['testText']);
$this->assertCount(3, $data['typetest']['edges'][0]['node']['testText']);
}
}
24 changes: 3 additions & 21 deletions test/Feature/Type/DateImmutableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,7 @@ public function testBetween(): void
'query' => new ObjectType([
'name' => 'query',
'fields' => [
'typetest' => [
'type' => $driver->connection(TypeTest::class),
'args' => [
'filter' => $driver->filter(TypeTest::class),
],
'resolve' => $driver->resolve(TypeTest::class),
],
'typetest' => $driver->completeConnection(TypeTest::class),
],
]),
]);
Expand Down Expand Up @@ -120,13 +114,7 @@ public function testBetweenLiteral(): void
'query' => new ObjectType([
'name' => 'query',
'fields' => [
'typetest' => [
'type' => $driver->connection(TypeTest::class),
'args' => [
'filter' => $driver->filter(TypeTest::class),
],
'resolve' => $driver->resolve(TypeTest::class),
],
'typetest' => $driver->completeConnection(TypeTest::class),
],
]),
]);
Expand Down Expand Up @@ -165,13 +153,7 @@ public function testInvalidLiteralValue(): void
'query' => new ObjectType([
'name' => 'query',
'fields' => [
'typetest' => [
'type' => $driver->connection(TypeTest::class),
'args' => [
'filter' => $driver->filter(TypeTest::class),
],
'resolve' => $driver->resolve(TypeTest::class),
],
'typetest' => $driver->completeConnection(TypeTest::class),
],
]),
]);
Expand Down
24 changes: 3 additions & 21 deletions test/Feature/Type/DateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,7 @@ public function testBetween(): void
'query' => new ObjectType([
'name' => 'query',
'fields' => [
'typetest' => [
'type' => $driver->connection(TypeTest::class),
'args' => [
'filter' => $driver->filter(TypeTest::class),
],
'resolve' => $driver->resolve(TypeTest::class),
],
'typetest' => $driver->completeConnection(TypeTest::class),
],
]),
]);
Expand Down Expand Up @@ -120,13 +114,7 @@ public function testBetweenLiteral(): void
'query' => new ObjectType([
'name' => 'query',
'fields' => [
'typetest' => [
'type' => $driver->connection(TypeTest::class),
'args' => [
'filter' => $driver->filter(TypeTest::class),
],
'resolve' => $driver->resolve(TypeTest::class),
],
'typetest' => $driver->completeConnection(TypeTest::class),
],
]),
]);
Expand Down Expand Up @@ -165,13 +153,7 @@ public function testInvalidLiteralValue(): void
'query' => new ObjectType([
'name' => 'query',
'fields' => [
'typetest' => [
'type' => $driver->connection(TypeTest::class),
'args' => [
'filter' => $driver->filter(TypeTest::class),
],
'resolve' => $driver->resolve(TypeTest::class),
],
'typetest' => $driver->completeConnection(TypeTest::class),
],
]),
]);
Expand Down
8 changes: 1 addition & 7 deletions test/Feature/Type/DateTimeImmutableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,7 @@ public function testBetween(): void
'query' => new ObjectType([
'name' => 'query',
'fields' => [
'typetest' => [
'type' => $driver->connection(TypeTest::class),
'args' => [
'filter' => $driver->filter(TypeTest::class),
],
'resolve' => $driver->resolve(TypeTest::class),
],
'typetest' => $driver->completeConnection(TypeTest::class),
],
]),
]);
Expand Down
8 changes: 1 addition & 7 deletions test/Feature/Type/DateTimeTZImmutableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,7 @@ public function testBetween(): void
'query' => new ObjectType([
'name' => 'query',
'fields' => [
'typetest' => [
'type' => $driver->connection(TypeTest::class),
'args' => [
'filter' => $driver->filter(TypeTest::class),
],
'resolve' => $driver->resolve(TypeTest::class),
],
'typetest' => $driver->completeConnection(TypeTest::class),
],
]),
]);
Expand Down
11 changes: 1 addition & 10 deletions test/Feature/Type/DateTimeTZTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,7 @@ public function testBetween(): void
'query' => new ObjectType([
'name' => 'query',
'fields' => [
'typetest' => [
'type' => $driver->connection(TypeTest::class),
'args' => [
'filter' => $driver->filter(TypeTest::class),
],
'resolve' => $driver->resolve(TypeTest::class),
],
'typetest' => $driver->completeConnection(TypeTest::class),
],
]),
]);
Expand All @@ -78,8 +72,5 @@ public function testBetween(): void
$data = $result->toArray()['data'];

$this->assertTrue(true);

// $this->assertEquals(1, count($data['typetest']['edges']));
// $this->assertEquals(1, $data['typetest']['edges'][0]['node']['id']);
}
}
8 changes: 1 addition & 7 deletions test/Feature/Type/DateTimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,7 @@ public function testBetween(): void
'query' => new ObjectType([
'name' => 'query',
'fields' => [
'typetest' => [
'type' => $driver->connection(TypeTest::class),
'args' => [
'filter' => $driver->filter(TypeTest::class),
],
'resolve' => $driver->resolve(TypeTest::class),
],
'typetest' => $driver->completeConnection(TypeTest::class),
],
]),
]);
Expand Down
8 changes: 1 addition & 7 deletions test/Feature/Type/JsonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,7 @@ public function testContains(): void
'query' => new ObjectType([
'name' => 'query',
'fields' => [
'typetest' => [
'type' => $driver->connection(TypeTest::class),
'args' => [
'filter' => $driver->filter(TypeTest::class),
],
'resolve' => $driver->resolve(TypeTest::class),
],
'typetest' => $driver->completeConnection(TypeTest::class),
],
]),
]);
Expand Down
27 changes: 3 additions & 24 deletions test/Feature/Type/PageInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,7 @@ public function testPageInfo(): void
'query' => new ObjectType([
'name' => 'query',
'fields' => [
'performance' => [
'type' => $driver->connection(Performance::class),
'args' => [
'filter' => $driver->filter(Performance::class),
'pagination' => $driver->pagination(),
],
'resolve' => $driver->resolve(Performance::class),
],
'performance' => $driver->completeConnection(Performance::class),
],
]),
]);
Expand Down Expand Up @@ -73,14 +66,7 @@ public function testPageInfoHasNextPage(): void
'query' => new ObjectType([
'name' => 'query',
'fields' => [
'performance' => [
'type' => $driver->connection(Performance::class),
'args' => [
'filter' => $driver->filter(Performance::class),
'pagination' => $driver->pagination(),
],
'resolve' => $driver->resolve(Performance::class),
],
'performance' => $driver->completeConnection(Performance::class),
],
]),
]);
Expand Down Expand Up @@ -113,14 +99,7 @@ public function testPageInfoHasPreviousPage(): void
'query' => new ObjectType([
'name' => 'query',
'fields' => [
'performance' => [
'type' => $driver->connection(Performance::class),
'args' => [
'filter' => $driver->filter(Performance::class),
'pagination' => $driver->pagination(),
],
'resolve' => $driver->resolve(Performance::class),
],
'performance' => $driver->completeConnection(Performance::class),
],
]),
]);
Expand Down
Loading
Loading