
    Xj                        d dl mZ d dlmZ d dlmZ d dlmZmZm	Z	m
Z
 d dlmZ d dlmZ erd dlmZ d dlmZ  G d	 d
e      Z G d de      Z G d de      Zg dZy)    )annotations)Callable)cached_property)TYPE_CHECKINGOptionalTypecast)StrawberryException)SourceFinder)ExceptionSource)StrawberryResolverc                  2     e Zd Zd fdZedd       Z xZS )NodeIDAnnotationErrorc                    || _         || _        d| j                   j                   d| _        d| _        d| _        t        |   | j                         y )NzQExpected exactly one `relay.NodeID` annotated field to be defined in `[underline]z
[/]` type.zTo fix this error you should annotate exactly one of your fields using `relay.NodeID`. That field should be unique among your type objects (usually its `id` for ORM objects).z'node missing node id private annotation)clsmessage__name__rich_message
suggestionannotation_messagesuper__init__)selfr   r   	__class__s      h/var/www/html/myl_app/scheduler-service/venv/lib/python3.12/site-packages/strawberry/relay/exceptions.pyr   zNodeIDAnnotationError.__init__   s_    &&*hh&7&7%8
D 	
D 	
 #L&    c                f    | j                   y t               }|j                  | j                         S N)r   r   find_class_from_objectr   source_finders     r   exception_sourcez&NodeIDAnnotationError.exception_source!   s+    88$33DHH==r   )r   strr   r   returnNoner$   zOptional[ExceptionSource]r   
__module____qualname__r   r   r"   __classcell__r   s   @r   r   r      s    '" > >r   r   c                  2     e Zd Zd fdZedd       Z xZS )RelayWrongAnnotationErrorc                    || _         || _        d| d| _        d| j                   d| _        d| j                   d| d| d| _        d	| _        t        |   | j                         y )
Nz Wrong annotation used on field "z7". It should be annotated with a "Connection" subclass.z'Wrong annotation for field `[underline]z[/]`z@To fix this error you can add a valid annotation, like [italic]`z: relay.Connection[z2]` or [italic]`@relay.connection(relay.Connection[z])`zrelay wrong annotation)r   
field_namer   r   r   r   r   r   )r   r/   r   r   s      r   r   z"RelayWrongAnnotationError.__init__,   s    $ /zl ;6 6 	
 6doo5FdK 	!__--@ F>>AU#G 	
 #;&r   c                |    | j                   y t               }|j                  | j                   | j                        S r   )r   r    find_class_attribute_from_objectr/   r    s     r   r"   z*RelayWrongAnnotationError.exception_source@   s1    88$==dhhXXr   )r/   r#   r   r   r$   r%   r&   r'   r+   s   @r   r-   r-   +   s    '( Y Yr   r-   c                  2     e Zd Zd fdZedd       Z xZS )!RelayWrongResolverAnnotationErrorc                    |j                   | _        || _        d| d| _        d| d| _        d| _        d| _        t        | !  | j                         y )NzWrong annotation used on "zE" resolver. It should be return an iterable or async iterable object.zWrong annotation used on `zI` resolver. It should be return an `iterable` or `async iterable` object.a   To fix this error you can annootate your resolver to return one of the following options: `List[<NodeType>]`, `Iterator[<NodeType>]`, `Iterable[<NodeType>]`, `AsyncIterator[<NodeType>]`, `AsyncIterable[<NodeType>]`, `Generator[<NodeType>, Any, Any]` and `AsyncGenerator[<NodeType>, Any]`.zrelay wrong resolver annotation)	wrapped_funcfunctionr/   r   r   r   r   r   r   )r   r/   resolverr   s      r   r   z*RelayWrongResolverAnnotationError.__init__J   sx     --$ ) 5H H 	
 ) 5L L 	
1 	 #D&r   c                    | j                   y t               }|j                  t        t        | j                               S r   )r6   r   find_function_from_objectr	   r   r    s     r   r"   z2RelayWrongResolverAnnotationError.exception_sourceb   s2    == $66tHdmm7TUUr   )r/   r#   r7   r   r$   r%   r&   r'   r+   s   @r   r3   r3   I   s    '0 V Vr   r3   )r   r-   r3   N)
__future__r   collections.abcr   	functoolsr   typingr   r   r   r	   strawberry.exceptions.exceptionr
   )strawberry.exceptions.utils.source_finderr   &strawberry.exceptions.exception_sourcer    strawberry.types.fields.resolverr   r   r-   r3   __all__ r   r   <module>rD      sV    " $ % 6 6 ? BFC>/ >8Y 3 Y<V(; VDr   