Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

+22 -17
View File
@@ -10,25 +10,29 @@
*/
namespace IPS\blog\api\GraphQL\Queries;
use GraphQL\Type\Definition\ObjectType;
use IPS\Api\GraphQL\SafeException;
use IPS\Api\GraphQL\TypeRegistry;
use IPS\blog\api\GraphQL\Types\EntryType;
use IPS\blog\Entry as EntryClass;
use OutOfRangeException;
use function defined;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Entry query for GraphQL API
*/
class _Entry
class Entry
{
/*
* @brief Query description
*/
public static $description = "Returns a Blog Entry";
public static string $description = "Returns a Blog Entry";
/*
* Query arguments
@@ -43,7 +47,7 @@ class _Entry
/**
* Return the query return type
*/
public function type()
public function type(): EntryType
{
return \IPS\blog\api\GraphQL\TypeRegistry::entry();
}
@@ -51,25 +55,26 @@ class _Entry
/**
* Resolves this query
*
* @param mixed Value passed into this resolver
* @param array Arguments
* @param array Context values
* @return \IPS\blog\Entry
*/
public function resolve($val, $args, $context, $info)
{
* @param mixed $val Value passed into this resolver
* @param array $args Arguments
* @param array $context Context values
* @param array $info
* @return EntryClass
*/
public function resolve( mixed $val, array $args, array $context, array $info): EntryClass
{
try
{
$entry = \IPS\blog\Entry::loadAndCheckPerms( $args['id'] );
$entry = EntryClass::loadAndCheckPerms( $args['id'] );
}
catch ( \OutOfRangeException $e )
catch ( OutOfRangeException )
{
throw new \IPS\Api\GraphQL\SafeException( 'NO_TOPIC', '2B300/A_graphql', 400 );
throw new SafeException( 'NO_TOPIC', '2B300/A_graphql', 400 );
}
if( !$entry->can('read') )
{
throw new \IPS\Api\GraphQL\SafeException( 'NO_PERMISSION', '2B300/9_graphql', 403 );
throw new SafeException( 'NO_PERMISSION', '2B300/9_graphql', 403 );
}
return $entry;