Skip to content

Commit

Permalink
Merge pull request API-Skeletons#85 from TomHAnderson/feature/types-c…
Browse files Browse the repository at this point in the history
…onnection-node-2

Feature/types connection node 2
  • Loading branch information
TomHAnderson authored Mar 27, 2024
2 parents 3924e91 + 0dbd3b2 commit da88b5d
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This library **does not** try to redefine how the excellent library [webonyx/gra

Please read the [detailed documentation](https://doctrine-orm-graphql.apiskeletons.dev/en/latest/).

For an example implementation post to `https://graphql.lcdb.org/`
For an example implementation see `https://graphql.lcdb.org/`

For an example application see [https://github.com/lcdborg/graphql.lcdb.org](https://github.com/lcdborg/graphql.lcdb.org)

Expand Down
2 changes: 1 addition & 1 deletion src/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function connection(string $id): ObjectType
$objectType = $this->type($id);

return $this->get(Type\TypeManager::class)
->build(Type\Connection::class, 'Connection_' . $objectType->name, $objectType);
->build(Type\Connection::class, $objectType->name, $objectType);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Filter/FilterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use function in_array;
use function md5;
use function serialize;
use function ucwords;

use const SORT_REGULAR;

Expand Down Expand Up @@ -53,7 +54,7 @@ public function get(
array|null $associationMetadata = null,
): GraphQLInputObjectType {
$typeName = $owningEntity ?
'Filter_' . $owningEntity->getTypeName() . '_' . $associationName
'Filter_' . $owningEntity->getTypeName() . '_' . ucwords($associationName)
: 'Filter_' . $targetEntity->getTypeName();

if ($this->typeManager->has($typeName)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Type/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct(AbstractContainer $container, string $typeName, arra
$objectType = $params[0];

$configuration = [
'name' => $typeName,
'name' => 'Connection_' . $typeName,
'description' => 'Connection for ' . $typeName,
'fields' => [
'edges' => Type::listOf($container
Expand Down
5 changes: 3 additions & 2 deletions src/Type/Entity/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use function assert;
use function in_array;
use function ksort;
use function ucwords;

use const SORT_REGULAR;

Expand Down Expand Up @@ -202,12 +203,12 @@ protected function addAssociations(array &$fields): void
$targetEntity = $associationMetadata['targetEntity'];
$fields[$associationName] = function () use ($targetEntity, $associationName) {
$entity = $this->entityTypeManager->get($targetEntity);
$shortName = $this->getTypeName() . '_' . $associationName;
$shortName = $this->getTypeName() . '_' . ucwords($associationName);

return [
'type' => $this->typeManager->build(
Connection::class,
'Connection_' . $shortName,
$shortName,
$entity->getObjectType(),
),
'args' => [
Expand Down
8 changes: 4 additions & 4 deletions test/Feature/Type/TypeManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public function testBuild(): void
$typeManager = $driver->get(TypeManager::class);

$objectType = $driver->type(Artist::class);
$connection = $typeManager->build(Connection::class, $objectType->name . '_Connection', $objectType);
$this->assertEquals($objectType->name . '_Connection', $connection->name);
$connection = $typeManager->build(Connection::class, $objectType->name, $objectType);
$this->assertEquals('Connection_' . $objectType->name, $connection->name);
}

public function testBuildTwiceReturnsSameType(): void
Expand All @@ -28,8 +28,8 @@ public function testBuildTwiceReturnsSameType(): void
$typeManager = $driver->get(TypeManager::class);

$objectType = $driver->type(Artist::class);
$connection1 = $typeManager->build(Connection::class, $objectType->name . '_Connection', $objectType);
$connection2 = $typeManager->build(Connection::class, $objectType->name . '_Connection', $objectType);
$connection1 = $typeManager->build(Connection::class, $objectType->name, $objectType);
$connection2 = $typeManager->build(Connection::class, $objectType->name, $objectType);

$this->assertSame($connection1, $connection2);
}
Expand Down

0 comments on commit da88b5d

Please sign in to comment.