
    XjB                    `   d dl mZ d dlZd dlZd dlZd dlmZ d dlmZ d dl	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ d dlmZmZ d dl m!Z! d dl"m#Z#m$Z$m%Z% d d	l&m'Z'm(Z( d d
l)m*Z*m+Z+ d dl,m-Z-m.Z. d dl/m0Z0m1Z1m2Z2 d dl3m4Z4 d dl5m6Z6 d dl7m8Z8 d dl9m:Z:m;Z; ddl<m=Z=m>Z>m?Z?m@Z@mAZA e
rd dlmBZB d dlCmDZD d dlEmFZF  G d de$      ZG G d de$      ZHe
re2ZInd&dZIe	 d'dddddddej                  ej                  dddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d(d       ZKe	 d'dddddej                  ej                  dddd 
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d)d!       ZK	 d'ddddddej                  ej                  ddddd"	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d*d#ZKd$d%gZLy)+    )annotationsN)defaultdict)AsyncIterable)TYPE_CHECKINGAnyAsyncIterator	AwaitableCallableDefaultDictDict
ForwardRefIterableIteratorListMappingOptionalSequenceTupleTypeUnioncastoverload)	Annotated
get_origin)StrawberryAnnotation)AsyncExtensionResolverFieldExtensionSyncExtensionResolver)RelayWrongAnnotationError!RelayWrongResolverAnnotationError)StrawberryArgumentargument)StrawberryListStrawberryOptional)_RESOLVER_TYPEStrawberryFieldfield)StrawberryResolver)LazyTypeasyncgen_to_list)	eval_typeis_generic_alias   )
ConnectionGlobalIDNodeNodeIterableTypeNodeType)Literal)BasePermission)Infoc                  l    e Zd ZddZ	 	 	 	 	 	 	 	 	 	 ddZ	 	 	 	 	 	 	 	 	 	 ddZ	 	 	 	 d	dZ	 	 	 	 d
dZy)NodeExtensionc                    |j                   J t        |j                  t              r| j	                  |      }n| j                  |      }t        ||j                        |_         y )N)type_override)base_resolver
isinstancetyper#   get_node_list_resolverget_node_resolverr(   )selfr'   resolvers      d/var/www/html/myl_app/scheduler-service/venv/lib/python3.12/site-packages/strawberry/relay/fields.pyapplyzNodeExtension.apply;   sU    ""***ejj.12259H--e4H0T    c                     |||fi |S N )r@   next_sourceinfokwargss        rB   resolvezNodeExtension.resolveE   s     VT,V,,rD   c                d   K    |||fi |}t        j                  |      r
| d {   S |S 7 wrF   )inspectisawaitable)r@   rH   rI   rJ   rK   retvals         rB   resolve_asynczNodeExtension.resolve_asyncJ   s7      vt.v.
  '226:V|FF|s   %0.0c                X    |j                   }t        |t              	 	 	 	 	 	 dfd}|S )Nc                `    |j                  |       j                  |j                  |        S )N)rJ   required)resolve_typeresolve_nodenode_id)rJ   idis_optionals     rB   rA   z1NodeExtension.get_node_resolver.<locals>.resolverZ   s5     ??4(55

( 6  rD   )rJ   r6   rX   zBAnnotated[GlobalID, argument(description='The ID of the object.')]returnz/Union[Node, None, Awaitable[Union[Node, None]]])r=   r<   r$   r@   r'   type_rA   rY   s       @rB   r?   zNodeExtension.get_node_resolverT   sA     

 (:;		R	 =	 rD   c                    |j                   }t        |t              sJ t        |j                  t              	 	 	 	 	 	 dfd}|S )Nc                B  
 t        t              }i D ]G  }|j                  |       }||   j                  |j                         |t        ||         dz
  f|<   I |j                         D ci c]  \  }}||j                  | |        }}}|j                         D ci c]  \  }}t        j                  |      r|| c}}|j                         D ci c]  \  }}t        j                  |      r|| c}}
s
r|fd
fd} |       S |j                         D ci c]&  \  }}|t        t        t        t           |            ( }	}}D cg c]  }|	|   d      |   d       c}S c c}}w c c}}w c c}}w c c}}w c c}w )Nr.   )rJ   node_idsrT   c                  K   | j                  t        g j                         j                         t        j                  g j                         d j                         D          d {                | j                         D ci c]  \  }}|t        |       } }}D cg c]  }| |   d      |   d       c}S 7 Zc c}}w c c}w w)Nc              3  2   K   | ]  }t        |        y wrF   r*   ).0nodess     rB   	<genexpr>zZNodeExtension.get_node_list_resolver.<locals>.resolver.<locals>.resolve.<locals>.<genexpr>   s      ""(- %5U$;""s   r   r.   )updatezipkeysasynciogathervaluesitemslist)resolvednode_trc   gidasyncgen_nodesawaitable_nodesids	index_maps       rB   rL   zGNodeExtension.get_node_list_resolver.<locals>.resolver.<locals>.resolve   s     OO!0!5!5!7!/!4!4!6
 #*.. #!0!7!7!9#""1?1F1F1H""# & BJAQ 0=U+ H   SVKN3!23IcN14EF  s0   A/C2C3CC(C/C
CCr   )rm   r   rZ   z
List[Node])r   rl   rU   appendrW   lenrk   resolve_nodesrN   rO   
isasyncgenr   r   r1   )rJ   rr   	nodes_mapro   rn   r_   resolved_nodesrc   rL   rm   rp   rq   rs   rY   s    `        @@@rB   rA   z6NodeExtension.get_node_list_resolver.<locals>.resolverm   s    =H<MI ACI F))$/&!((5"(#i.?*@1*D!E	#F )2(9 %FH ,,%!,_ -  N  &4%9%9%;!FE&&u- O &4%9%9%;!FE%%e, N .2@  4 y 
 &4%9%9%;!FE T(4.%899H  ORRsHYs^A./	#q0ABRRoJ Ss   6 F,"F
%"F4+F&F)rJ   r6   rr   zJAnnotated[List[GlobalID], argument(description='The IDs of the objects.')]rZ   z(Union[List[Node], Awaitable[List[Node]]])r=   r<   r#   of_typer$   r[   s       @rB   r>   z$NodeExtension.get_node_list_resolverf   s`     

%000 0BCG	SG	SG	S
 6G	SR rD   Nr'   r&   rZ   None)
rH   r   rI   r   rJ   r6   rK   r   rZ   r   )r'   r&   rZ   zKCallable[[Info, GlobalID], Union[Node, None, Awaitable[Union[Node, None]]]])r'   r&   rZ   zJCallable[[Info, List[GlobalID]], Union[List[Node], Awaitable[List[Node]]]])__name__
__module____qualname__rC   rL   rQ   r?   r>   rG   rD   rB   r8   r8   :   s    U-*-47-?C-OR-	-
G*G47G?CGORG	G$	T$P$P	SPrD   r8   c                      e Zd ZU ded<   ddZddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d	dZddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d
dZy)ConnectionExtensionzType[Connection[Node]]connection_typec           	     d   g |j                   t        dd t        t        t                 dd       t        dd t        t        t                 dd       t        dd t        t        t
                 dd       t        dd t        t        t
                 dd       |_         |j                  }t        |t              r|j                         }||_        t        |      rt        |      n|}t        |t              rt        |t              s.t        |j                  t!        t        |j"                              |j$                  sJ |j$                  j&                  j(                  }t        |t              rt+        |      }t        |t*              r!t-        ||j$                  j.                  d       }t        |      }| t        |t0        t2        t4        t6        f      s t9        |j                  |j$                        t!        t:        t        t<              |j                        | _        y )	NbeforezDReturns the items in the list that come before the specified cursor.)python_namegraphql_nametype_annotationdescriptiondefaultafterzCReturns the items in the list that come after the specified cursor.firstz(Returns the first n items from the list.last) 	argumentsr!   r   r   strintr=   r<   r)   rU   r-   r   
issubclassr/   r   namer   originr;   	signaturereturn_annotationr   r,   
_namespacer   r   r   r   r    r   r1   r   )r@   r'   f_typetype_originresolver_typer   s         rB   rC   zConnectionExtension.apply   s   '
__'
$! 4Xc] C( 	'
 #! 4Xc] C( 	'
, #! 4Xc] CF-'
: "! 4Xc] C( 	;'
R fh'((*FEJ,<V,Dj(&+t,J{J4W+EJJT5<<8PQQ"""" ++55GGmS)&}5MmZ0%##..M M*>XxF"
 4EJJ@S@STT#DD)9$:EJJGrD   N)r   r   r   r   c          
         | j                   J | j                   j                  t        t        t            |||fi |      |||||      S N)rJ   r   r   r   r   )r   resolve_connectionr   r   r1   )	r@   rH   rI   rJ   r   r   r   r   rK   s	            rB   rL   zConnectionExtension.resolve  s]     ##///##66$vt!>v!>? 7 
 	
rD   c               .  K   | j                   J  |||fi |}	t        j                  |	      r
|	 d {   }	| j                   j                  t	        t
        t           |	      |||||      }
t        j                  |
      r
|
 d {   }
|
S 7 [7 wr   )r   rN   rO   r   r   r   r1   )r@   rH   rI   rJ   r   r   r   r   rK   rc   rm   s              rB   rQ   z!ConnectionExtension.resolve_async  s      ##///fd-f- u%KE''::$' ; 
 x(%~H   &s"   3BBAB
BBBr{   )rH   r   rI   r   rJ   r6   r   Optional[str]r   r   r   Optional[int]r   r   rK   r   rZ   r   )rH   r   rI   r   rJ   r6   r   r   r   r   r   r   r   r   rK   r   rZ   r   )r}   r~   r   __annotations__rC   rL   rQ   rG   rD   rB   r   r      s    ++JHd !%##"
$
 
 	
 
 
 
 
 
 

8 !%##" %    	            
 rD   r   c                 Z    g |j                  dg       t               |d<   t        | i |S )N
extensions)getr8   r'   )argsrK   s     rB   noder   E  s3    OL"!=O}O|d%f%%rD   FTrG   )rA   r   is_subscriptionr   initpermission_classesdeprecation_reasonr   default_factorymetadata
directivesr   c                    y rF   rG   )graphql_typerA   r   r   r   r   r   r   r   r   r   r   r   s                rB   
connectionr   J  s      rD   )
r   r   r   r   r   r   r   r   r   r   c       
             y rF   rG   )r   r   r   r   r   r   r   r   r   r   r   s              rB   r   r   ]  s     rD   )rA   r   r   r   r   r   r   r   r   r   r   r   c                   t        d||t        j                  |       ||xs g ||||	|
xs dg |t                     }| ||      }|S )a*
  Annotate a property or a method to create a relay connection field.

    Relay connections are mostly used for pagination purposes. This decorator
    helps creating a complete relay endpoint that provides default arguments
    and has a default implementation for the connection slicing.

    Note that when setting a resolver to this field, it is expected for this
    resolver to return an iterable of the expected node type, not the connection
    itself. That iterable will then be paginated accordingly. So, the main use
    case for this is to provide a filtered iterable of nodes by using some custom
    filter arguments.

    Args:
        graphql_type: The type of the nodes in the connection. This is used to
            determine the type of the edges and the node field in the connection.
        resolver: The resolver for the connection. This is expected to return an
            iterable of the expected node type.
        name: The GraphQL name of the field.
        is_subscription: Whether the field is a subscription.
        description: The GraphQL description of the field.
        permission_classes: The permission classes to apply to the field.
        deprecation_reason: The deprecation reason of the field.
        default: The default value of the field.
        default_factory: The default factory of the field.
        metadata: The metadata of the field.
        directives: The directives to apply to the field.
        extensions: The extensions to apply to the field.
        init: Used only for type checking purposes.

    Examples:
    Annotating something like this:

    ```python
    @strawberry.type
    class X:
        some_node: relay.Connection[SomeType] = relay.connection(
            resolver=get_some_nodes,
            description="ABC",
        )

        @relay.connection(relay.Connection[SomeType], description="ABC")
        def get_some_nodes(self, age: int) -> Iterable[SomeType]: ...
    ```

    Will produce a query like this:

    ```graphql
    query {
        someNode (
            before: String
            after: String
            first: String
            after: String
            age: Int
        ) {
            totalCount
            pageInfo {
                hasNextPage
                hasPreviousPage
                startCursor
                endCursor
            }
            edges {
                cursor
                node {
                    id
                    ...
                }
            }
        }
    }
    ```

    .. _Relay connections:
        https://relay.dev/graphql/connections.htm

    NrG   )r   r   r   r   r   r   r   r   r   r   r   r   )r&   r   from_annotationr   )r   rA   r   r   r   r   r   r   r   r   r   r   r   fs                 rB   r   r   n  sl    @ 	,<<\J'-3-'#7Z7!4!67	A hKHrD   r   r   )r   r   rK   r   rZ   r&   rF   )r   $Optional[Type[Connection[NodeType]]]rA   z/Optional[_RESOLVER_TYPE[NodeIterableType[Any]]]r   r   r   boolr   r   r   zLiteral[True]r   $Optional[List[Type[BasePermission]]]r   r   r   r   r   $Union[Callable[..., object], object]r   Optional[Mapping[Any, Any]]r   Optional[Sequence[object]]r   List[FieldExtension]rZ   r   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rZ   r&   )r   r   rA   zOptional[_RESOLVER_TYPE[Any]]r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   zLiteral[True, False, None]rZ   r   )M
__future__r   rh   dataclassesrN   collectionsr   collections.abcr   typingr   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   typing_extensionsr   r   strawberry.annotationr   %strawberry.extensions.field_extensionr   r   r   strawberry.relay.exceptionsr   r    strawberry.types.argumentsr!   r"   strawberry.types.baser#   r$   strawberry.types.fieldr%   r&   r'    strawberry.types.fields.resolverr(   strawberry.types.lazy_typer)   strawberry.utils.aior+   strawberry.utils.typingr,   r-   typesr/   r0   r1   r2   r3   r4   strawberry.permissionr5   strawberry.types.infor6   r8   r   r   MISSINGr   __all__rG   rD   rB   <module>r      s(   "    # )     * 4 6 
 D D I I ? / 1 ? I I)4*|N |~E. EP D&
 
9= AE!!%?C(,&&<G<O<O,0-/')6 > 	
    = &  : * + % 	 
$ 
9= !!%?C(,&&<G<O<O,0-/')6  	
  = &  : * + %  
" :>p /3!!%?C(,&&<G<O<O,0-/') (,#p6p ,p 	p
 p p =p &p p :p *p +p %p" %#p$ 	%pf <
 rD   