Docblocks improvements

This commit is contained in:
Vladimir Razuvaev 2017-08-20 22:10:13 +07:00
parent d5e3d08d85
commit de791536ce
6 changed files with 40 additions and 13 deletions

View File

@ -1,6 +1,9 @@
<?php <?php
namespace GraphQL\Type\Definition; namespace GraphQL\Type\Definition;
/**
* List of available directive locations
*/
class DirectiveLocation class DirectiveLocation
{ {
const IFACE = 'INTERFACE'; const IFACE = 'INTERFACE';

View File

@ -70,7 +70,7 @@ abstract class Type implements \JsonSerializable
/** /**
* @api * @api
* @param ObjectType|InterfaceType|UnionType|ScalarType|InputObjectType|EnumType $wrappedType * @param ObjectType|InterfaceType|UnionType|ScalarType|InputObjectType|EnumType|ListOfType|NonNull $wrappedType
* @return ListOfType * @return ListOfType
*/ */
public static function listOf($wrappedType) public static function listOf($wrappedType)
@ -80,7 +80,7 @@ abstract class Type implements \JsonSerializable
/** /**
* @api * @api
* @param ObjectType|InterfaceType|UnionType|ScalarType|InputObjectType|EnumType $wrappedType * @param ObjectType|InterfaceType|UnionType|ScalarType|InputObjectType|EnumType|ListOfType $wrappedType
* @return NonNull * @return NonNull
*/ */
public static function nonNull($wrappedType) public static function nonNull($wrappedType)

View File

@ -35,8 +35,7 @@ use GraphQL\Type\Schema;
use GraphQL\Utils\Utils; use GraphQL\Utils\Utils;
/** /**
* Class AST * Various utilities dealing with AST
* @package GraphQL\Utils
*/ */
class AST class AST
{ {
@ -59,8 +58,9 @@ class AST
* Will produce instance of `ListValueNode` where `values` prop is a lazily-evaluated `NodeList` * Will produce instance of `ListValueNode` where `values` prop is a lazily-evaluated `NodeList`
* returning instances of `StringValueNode` on access. * returning instances of `StringValueNode` on access.
* *
* This is a reverse operation for $node->toArray(true) * This is a reverse operation for AST::toArray($node)
* *
* @api
* @param array $node * @param array $node
* @return Node * @return Node
*/ */
@ -98,6 +98,7 @@ class AST
/** /**
* Convert AST node to serializable array * Convert AST node to serializable array
* *
* @api
* @param Node $node * @param Node $node
* @return array * @return array
*/ */
@ -124,6 +125,7 @@ class AST
* | Mixed | Enum Value | * | Mixed | Enum Value |
* | null | NullValue | * | null | NullValue |
* *
* @api
* @param $value * @param $value
* @param InputType $type * @param InputType $type
* @return ObjectValueNode|ListValueNode|BooleanValueNode|IntValueNode|FloatValueNode|EnumValueNode|StringValueNode|NullValueNode * @return ObjectValueNode|ListValueNode|BooleanValueNode|IntValueNode|FloatValueNode|EnumValueNode|StringValueNode|NullValueNode
@ -267,8 +269,9 @@ class AST
* | String | String | * | String | String |
* | Int / Float | Int / Float | * | Int / Float | Int / Float |
* | Enum Value | Mixed | * | Enum Value | Mixed |
* | Null Value | stdClass | instance of NullValue::getNullValue() * | Null Value | null |
* *
* @api
* @param $valueNode * @param $valueNode
* @param InputType $type * @param InputType $type
* @param null $variables * @param null $variables
@ -396,6 +399,9 @@ class AST
} }
/** /**
* Returns type definition for given AST Type node
*
* @api
* @param Schema $schema * @param Schema $schema
* @param NamedTypeNode|ListTypeNode|NonNullTypeNode $inputTypeNode * @param NamedTypeNode|ListTypeNode|NonNullTypeNode $inputTypeNode
* @return Type * @return Type
@ -430,6 +436,9 @@ class AST
} }
/** /**
* Returns operation type ("query", "mutation" or "subscription") given a document and operation name
*
* @api
* @param DocumentNode $document * @param DocumentNode $document
* @param string $operationName * @param string $operationName
* @return bool * @return bool

View File

@ -33,8 +33,8 @@ use GraphQL\Type\Definition\UnionType;
use GraphQL\Type\Introspection; use GraphQL\Type\Introspection;
/** /**
* Class BuildSchema * Build instance of `GraphQL\Type\Schema` out of type language definition (string or parsed AST)
* @package GraphQL\Utils * See [section in docs](type-system/type-language.md) for details.
*/ */
class BuildSchema class BuildSchema
{ {
@ -72,9 +72,10 @@ class BuildSchema
* If no schema definition is provided, then it will look for types named Query * If no schema definition is provided, then it will look for types named Query
* and Mutation. * and Mutation.
* *
* Given that AST it constructs a GraphQLSchema. The resulting schema * Given that AST it constructs a GraphQL\Type\Schema. The resulting schema
* has no resolve methods, so execution will use default resolvers. * has no resolve methods, so execution will use default resolvers.
* *
* @api
* @param DocumentNode $ast * @param DocumentNode $ast
* @param callable $typeConfigDecorator * @param callable $typeConfigDecorator
* @return Schema * @return Schema
@ -608,6 +609,7 @@ class BuildSchema
* A helper function to build a GraphQLSchema directly from a source * A helper function to build a GraphQLSchema directly from a source
* document. * document.
* *
* @api
* @param DocumentNode|Source|string $source * @param DocumentNode|Source|string $source
* @param callable $typeConfigDecorator * @param callable $typeConfigDecorator
* @return Schema * @return Schema

View File

@ -14,11 +14,15 @@ use GraphQL\Type\Definition\UnionType;
use GraphQL\Type\Definition\Directive; use GraphQL\Type\Definition\Directive;
/** /**
* Class SchemaPrinter * Given an instance of Schema, prints it in GraphQL type language.
* @package GraphQL\Utils
*/ */
class SchemaPrinter class SchemaPrinter
{ {
/**
* @api
* @param Schema $schema
* @return string
*/
public static function doPrint(Schema $schema) public static function doPrint(Schema $schema)
{ {
return self::printFilteredSchema($schema, function($n) { return self::printFilteredSchema($schema, function($n) {
@ -26,6 +30,11 @@ class SchemaPrinter
}, 'self::isDefinedType'); }, 'self::isDefinedType');
} }
/**
* @api
* @param Schema $schema
* @return string
*/
public static function printIntrosepctionSchema(Schema $schema) public static function printIntrosepctionSchema(Schema $schema)
{ {
return self::printFilteredSchema($schema, [__CLASS__, 'isSpecDirective'], [__CLASS__, 'isIntrospectionType']); return self::printFilteredSchema($schema, [__CLASS__, 'isSpecDirective'], [__CLASS__, 'isIntrospectionType']);

View File

@ -8,6 +8,8 @@ $outputFile = __DIR__ . '/../docs/reference.md';
$entries = [ $entries = [
\GraphQL\GraphQL::class, \GraphQL\GraphQL::class,
\GraphQL\Type\Definition\Type::class, \GraphQL\Type\Definition\Type::class,
\GraphQL\Type\Definition\ResolveInfo::class,
\GraphQL\Type\Definition\DirectiveLocation::class => ['constants' => true],
\GraphQL\Type\SchemaConfig::class, \GraphQL\Type\SchemaConfig::class,
\GraphQL\Type\Schema::class, \GraphQL\Type\Schema::class,
\GraphQL\Language\Parser::class, \GraphQL\Language\Parser::class,
@ -17,7 +19,6 @@ $entries = [
\GraphQL\Executor\Executor::class, \GraphQL\Executor\Executor::class,
\GraphQL\Executor\ExecutionResult::class, \GraphQL\Executor\ExecutionResult::class,
\GraphQL\Executor\Promise\PromiseAdapter::class, \GraphQL\Executor\Promise\PromiseAdapter::class,
\GraphQL\Type\Definition\ResolveInfo::class,
\GraphQL\Validator\DocumentValidator::class, \GraphQL\Validator\DocumentValidator::class,
\GraphQL\Error\Error::class => ['constants' => true, 'methods' => true, 'props' => true], \GraphQL\Error\Error::class => ['constants' => true, 'methods' => true, 'props' => true],
\GraphQL\Error\Warning::class => ['constants' => true, 'methods' => true], \GraphQL\Error\Warning::class => ['constants' => true, 'methods' => true],
@ -27,7 +28,10 @@ $entries = [
\GraphQL\Server\StandardServer::class, \GraphQL\Server\StandardServer::class,
\GraphQL\Server\ServerConfig::class, \GraphQL\Server\ServerConfig::class,
\GraphQL\Server\Helper::class, \GraphQL\Server\Helper::class,
\GraphQL\Server\OperationParams::class \GraphQL\Server\OperationParams::class,
\GraphQL\Utils\BuildSchema::class,
\GraphQL\Utils\AST::class,
\GraphQL\Utils\SchemaPrinter::class
]; ];
function renderClassMethod(ReflectionMethod $method) { function renderClassMethod(ReflectionMethod $method) {