-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathArticleController.php
More file actions
46 lines (37 loc) · 1.19 KB
/
ArticleController.php
File metadata and controls
46 lines (37 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
declare(strict_types=1);
namespace TheCodingMachine\GraphQLite\Fixtures\Integration\Controllers;
use TheCodingMachine\GraphQLite\Annotations\Cost;
use TheCodingMachine\GraphQLite\Annotations\Mutation;
use TheCodingMachine\GraphQLite\Annotations\Query;
use TheCodingMachine\GraphQLite\Fixtures\Integration\Models\Article;
use TheCodingMachine\GraphQLite\Fixtures\Integration\Models\UpdateArticleInput;
use TheCodingMachine\GraphQLite\Undefined;
class ArticleController
{
/** @return Article[] */
#[Query]
#[Cost(complexity: 5, multipliers: ['take'], defaultMultiplier: 500)]
public function articles(int|null $take = 10): array
{
return [
new Article('Title'),
];
}
#[Mutation]
public function createArticle(Article $article): Article
{
return $article;
}
#[Mutation]
public function updateArticle(UpdateArticleInput $input): Article
{
$article = new Article('test');
$article->magazine = 'The New Yorker';
$article->summary = $input->summary;
if ($input->magazine !== Undefined::VALUE) {
$article->magazine = $input->magazine;
}
return $article;
}
}