Skip to content

Commit ff515fa

Browse files
committed
Setup basic GraphQL mutations, queries
Using a simple, fictive domain with blogs and authors. Covering many features of jerowork/graphql-attribute-schema.
1 parent 16be232 commit ff515fa

File tree

24 files changed

+1153
-3
lines changed

24 files changed

+1153
-3
lines changed

composer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,16 @@
2020
"php": "^8.4",
2121
"ext-ctype": "*",
2222
"ext-iconv": "*",
23+
"ext-sqlite3": "*",
2324
"guzzlehttp/psr7": "^2.7",
2425
"jerowork/graphql-attribute-schema": "^0.3.1",
2526
"php-http/discovery": "^1.20",
2627
"psr/container": "^2.0",
28+
"ramsey/uuid": "^4.7",
2729
"symfony/console": "~7.2.6",
30+
"symfony/dependency-injection": "7.2.*",
2831
"symfony/dotenv": "~7.2.0",
32+
"symfony/event-dispatcher": "7.2.*",
2933
"symfony/flex": "^2.6",
3034
"symfony/framework-bundle": "~7.2.5",
3135
"symfony/http-foundation": "7.2.*",

composer.lock

Lines changed: 231 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/services.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ services:
1717
resource: '../src/'
1818
exclude:
1919
- '../src/DependencyInjection/'
20-
- '../src/Entity/'
2120
- '../src/Kernel.php'
2221

2322
# add more service definitions when explicit configuration is needed

src/Controller/.gitignore

Whitespace-only changes.

src/Domain/Author/Author.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Jerowork\ExampleApplicationGraphqlAttributeSchema\Domain\Author;
6+
7+
use Symfony\Component\DependencyInjection\Attribute\Exclude;
8+
9+
/**
10+
* Note: In an actual application, the domain layer contains all business logic
11+
* (optionally decoupled from the infrastructure layer by a command bus).
12+
* For the sake of this Proof of Concept, it's just a set of simple DTO's, as this project focuses on the GraphQL layer only.
13+
*/
14+
#[Exclude]
15+
final readonly class Author
16+
{
17+
public function __construct(
18+
public string $id,
19+
public string $name,
20+
public ?string $email,
21+
) {}
22+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Jerowork\ExampleApplicationGraphqlAttributeSchema\Domain\Author;
6+
7+
/**
8+
* Note: In an actual application, the domain layer contains all business logic
9+
* (optionally decoupled from the infrastructure layer by a command bus).
10+
* For the sake of this Proof of Concept, it's just a set of simple DTO's, as this project focuses on the GraphQL layer only.
11+
*/
12+
interface AuthorRepository
13+
{
14+
public function getById(string $authorId): Author;
15+
16+
public function save(Author $author): void;
17+
}

src/Domain/Blog/Blog.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Jerowork\ExampleApplicationGraphqlAttributeSchema\Domain\Blog;
6+
7+
use DateTimeImmutable;
8+
use Ramsey\Uuid\Uuid;
9+
use Symfony\Component\DependencyInjection\Attribute\Exclude;
10+
11+
/**
12+
* Note: In an actual application, the domain layer contains all business logic
13+
* (optionally decoupled from the infrastructure layer by a command bus).
14+
* For the sake of this Proof of Concept, it's just a set of simple DTO's, as this project focuses on the GraphQL layer only.
15+
*/
16+
#[Exclude]
17+
final readonly class Blog
18+
{
19+
/**
20+
* @param list<string> $tags
21+
*/
22+
public function __construct(
23+
public string $id,
24+
public BlogStatus $status,
25+
public string $title,
26+
public string $authorId,
27+
public array $tags,
28+
public DateTimeImmutable $publishedAt,
29+
) {}
30+
31+
/**
32+
* @param list<string> $tags
33+
*/
34+
public static function createDraft(
35+
string $title,
36+
string $authorId,
37+
array $tags,
38+
): self {
39+
return new self(
40+
(string) Uuid::uuid7(),
41+
BlogStatus::Draft,
42+
$title,
43+
$authorId,
44+
$tags,
45+
new DateTimeImmutable(),
46+
);
47+
}
48+
}

src/Domain/Blog/BlogRepository.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Jerowork\ExampleApplicationGraphqlAttributeSchema\Domain\Blog;
6+
7+
/**
8+
* Note: In an actual application, the domain layer contains all business logic
9+
* (optionally decoupled from the infrastructure layer by a command bus).
10+
* For the sake of this Proof of Concept, it's just a set of simple DTO's, as this project focuses on the GraphQL layer only.
11+
*/
12+
interface BlogRepository
13+
{
14+
public function getById(string $blogId): Blog;
15+
16+
public function getBlogs(
17+
BlogStatus $status,
18+
string $authorId,
19+
?int $first,
20+
?string $afterCursor,
21+
?int $last,
22+
?string $beforeCursor,
23+
): Blogs;
24+
25+
public function save(Blog $blog): void;
26+
}

0 commit comments

Comments
 (0)