<?php

declare(strict_types=1);

namespace App\Framework\GraphQL\Attributes;

use Attribute;

/**
 * Marks a property or method as a GraphQL field
 *
 * Type, name, nullability, and arguments are ALWAYS auto-detected from PHP:
 * - Field name from property/method name
 * - Type from PHP type hint
 * - Nullability from ?Type syntax
 * - Arguments from method parameters
 *
 * Usage:
 * #[GraphQLField(description: 'User email address')]
 * public Email $email;  // GraphQL: email: Email!
 *
 * #[GraphQLField(description: 'User posts')]
 * public function posts(int $limit = 10): array { ... }  // GraphQL: posts(limit: Int = 10): [Post]!
 *
 * #[GraphQLField(deprecated: true, deprecationReason: 'Use newField instead')]
 * public ?string $oldField;  // GraphQL: oldField: String @deprecated(reason: "Use newField instead")
 */
#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_METHOD)]
final readonly class GraphQLField
{
    public function __construct(
        public ?string $description = null,
        public bool $deprecated = false,
        public ?string $deprecationReason = null
    ) {
    }
}
