2022-03-08 09:54:38 +01:00
|
|
|
<?php
|
|
|
|
use GraphQL\Type\Definition\ObjectType;
|
|
|
|
use GraphQL\Type\Definition\Type;
|
|
|
|
|
2022-03-08 10:04:11 +01:00
|
|
|
require "./queries/skills.php";
|
2022-03-08 11:05:52 +01:00
|
|
|
require "./queries/blogPost.php";
|
2022-03-08 12:18:31 +01:00
|
|
|
require "./queries/comments.php";
|
2022-03-08 12:46:06 +01:00
|
|
|
require "./queries/mailAddress.php";
|
2022-03-08 10:04:11 +01:00
|
|
|
|
2022-03-08 09:54:38 +01:00
|
|
|
$queryType = new ObjectType([
|
|
|
|
'name' => 'Query',
|
|
|
|
'fields' => [
|
|
|
|
'sitekey' => [
|
|
|
|
'type' => Type::string(),
|
|
|
|
'resolve' => fn ($rootValue, $args) => $sitekey,
|
|
|
|
],
|
2022-03-08 12:46:06 +01:00
|
|
|
'mailAddress' => [
|
|
|
|
'type' => Type::string(),
|
|
|
|
"args" => [
|
|
|
|
"hCaptchaResponse" => Type::string()
|
|
|
|
],
|
|
|
|
'resolve' => fn ($rootValue, $args) => mailAddress($args["hCaptchaResponse"]),
|
|
|
|
],
|
2022-03-08 10:04:11 +01:00
|
|
|
'skills' => [
|
|
|
|
'type' => Type::listOf(Type::string()),
|
|
|
|
'resolve' => fn ($rootValue, $args) => getSkills(),
|
|
|
|
],
|
2022-03-08 11:05:52 +01:00
|
|
|
'blogPost' => [
|
|
|
|
"type" => $blogPostFields,
|
|
|
|
'args' => [
|
|
|
|
'id' => Type::nonNull(Type::string()),
|
|
|
|
],
|
|
|
|
'resolve' => fn ($rootValue, $args) => blogPost($args["id"], $rootValue["db"]),
|
|
|
|
],
|
2022-03-08 12:06:56 +01:00
|
|
|
'blogPosts' => [
|
|
|
|
"type" => Type::listOf($blogPostFields),
|
|
|
|
"args" => [
|
|
|
|
"count" => Type::nonNull(Type::int()),
|
|
|
|
"contentLength" => [
|
|
|
|
"type" => Type::int(),
|
|
|
|
"defaultValue" => null
|
|
|
|
]
|
|
|
|
|
|
|
|
],
|
|
|
|
'resolve' => fn ($rootValue, $args) => blogPosts($args["count"], $args["contentLength"], $rootValue["db"]),
|
2022-03-08 12:18:31 +01:00
|
|
|
],
|
|
|
|
'comments' => [
|
|
|
|
"type" => Type::listOf($commentField),
|
|
|
|
"args" => [
|
|
|
|
"article" => Type::nonNull(Type::string()),
|
|
|
|
],
|
|
|
|
'resolve' => fn ($rootValue, $args) => comments($args["article"], $rootValue["db"]),
|
2022-03-08 12:06:56 +01:00
|
|
|
]
|
2022-03-08 12:18:31 +01:00
|
|
|
|
2022-03-08 09:54:38 +01:00
|
|
|
],
|
|
|
|
]);
|