
    XjZJ                    *   d dl mZ d dlZd dlmZmZ d dl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mZmZmZmZmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
l m!Z! d dl"m#Z#m$Z$ d dl%m&Z& d dl'm(Z( d dl)m*Z* d dl+m,Z, d dl-m.Z.m/Z/ d dl0m1Z1 ddl2m3Z3 ddl4m5Z5 ddl6m7Z7 ddl8m9Z9 ddl:m:Z:m;Z; ddl<m=Z=m<Z< er2d dlm,Z> d dl?m@Z@ d dl+mAZA d dl-mBZB d dlCmDZD d dlEmFZF d dlGmHZHmIZI d d lJmKZK e1j                  e1j                  e1j                  hZO G d! d"e7      ZPd"gZQy)#    )annotationsN)cached_property	lru_cache)	TYPE_CHECKINGAnyDictIterableListOptionalTypeUnioncast)GraphQLBooleanGraphQLFieldGraphQLNamedTypeGraphQLNonNullGraphQLSchemaget_introspection_queryvalidate_schema)MiddlewareManager)specified_directives)relay)StrawberryAnnotation)SchemaExtension)DirectivesExtensionDirectivesExtensionSyncSchemaExtensionsRunner)GraphQLCoreConverter)DEFAULT_SCALAR_REGISTRYExecutionContext)StrawberryObjectDefinitionhas_object_definition)OperationType   print_schema   )compat)
BaseSchema)StrawberryConfig)executeexecute_sync)SubscriptionResult	subscribe)StrawberryDirective)ExecutionResult)StrawberryType)EnumDefinition)StrawberryField)ScalarDefinitionScalarWrapper)StrawberryUnionc                     e Zd Z	 	 	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZdddZedd       Zedd       Z	 	 	 	 	 	 ddZ	 	 	 	 ddZ		 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ
e	 	 	 	 dd	       Z	 	 	 	 	 	 dd
Zed d       Z	 	 	 	 d!dZ	 	 	 	 	 d"	 	 	 	 	 	 	 	 	 	 	 	 	 d#dZ	 	 	 	 	 d"	 	 	 	 	 	 	 	 	 	 	 	 	 d#dZ	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 d$dZd%dZd%dZd%dZd&dZeZd'dZy)(SchemaNc           	     p   || _         || _        || _        || _        d| _        || _        |xs
 t               | _        t        t        t        d   f   }i t        }|	r|j                  t        ||	             t        | j                  || j                        | _        || _        t%        |
      | _        | j                   j)                  |j*                        }|r%| j                   j)                  |j*                        nd}|r%| j                   j)                  |j*                        nd}|D cg c]  }| j                   j-                  |       }}g }|D ]  }t/        j0                  |      r+|j3                  | j                   j5                  |             Ct7        |      r/|j*                  j8                  rt;        |      j=                         }| j                   j?                  |      }tA        |tB              r|jD                  }tA        |tF              stI        | d      |j3                  |        	 tK        |||r|ndtL        tO        |      z   |t        jP                  | i      | _)        | | jR                  _-        | j]                          | j_                          | ja                          tc        | jR                        }|r&dje                  d |D              }tg        d	|       yc c}w # tH        $ r/}ddl*m+} tA        |jX                  |      r|jX                  d d}~ww xY w)
ab  Default Schema to be used in a Strawberry application.

        A GraphQL Schema class used to define the structure and configuration
        of GraphQL queries, mutations, and subscriptions.

        This class allows the creation of a GraphQL schema by specifying the types
        for queries, mutations, and subscriptions, along with various configuration
        options such as directives, extensions, and scalar overrides.

        Args:
            query: The entry point for queries.
            mutation: The entry point for mutations.
            subscription: The entry point for subscriptions.
            directives: A list of operation directives that clients can use.
                The bult-in `@include` and `@skip` are included by default.
            types: A list of additional types that will be included in the schema.
            extensions: A list of Strawberry extensions.
            execution_context_class: The execution context class.
            config: The configuration for the schema.
            scalar_overrides: A dictionary of overrides for scalars.
            schema_directives: A list of schema directives for the schema.

        Example:
        ```python
        import strawberry


        @strawberry.type
        class Query:
            name: str = "Patrick"


        schema = strawberry.Schema(query=Query)
        ```
        N)r7   r6   z is not a named GraphQL Type)querymutationsubscription
directivestypes
extensionsr   )StrawberryExceptionz

c              3  :   K   | ]  }d |j                      yw)u   ❌ N)message).0errors     e/var/www/html/myl_app/scheduler-service/venv/lib/python3.12/site-packages/strawberry/schema/schema.py	<genexpr>z"Schema.__init__.<locals>.<genexpr>   s     *VeT%--+A*Vs   zInvalid Schema. Errors:

)4r<   r=   r>   rA   _cached_middleware_managerexecution_context_classr,   configr   objectr   r    updater   r   
get_fieldsschema_converterr?   listschema_directivesfrom_object__strawberry_definition__from_directiver*   is_schema_directiveappendfrom_schema_directiver$   is_graphql_genericr   resolvefrom_maybe_optional
isinstancer   of_typer   	TypeErrorr   r   tupleDEFINITION_BACKREF_schemastrawberry.exceptionsrB   	__cause___strawberry_schema_warn_for_federation_directives_resolve_node_ids_extend_introspectionr   join
ValueError)selfr<   r=   r>   r?   r@   rA   rJ   rK   scalar_overridesrQ   SCALAR_OVERRIDES_DICT_TYPEscalar_registry
query_typemutation_typesubscription_type	directivegraphql_directivesgraphql_typestype_graphql_typerF   rB   errorsformatted_errorss                            rG   __init__zSchema.__init__E   s   h 
 ($DH''>$2 0 2%)E=>>&
" 7R9P6Q""4(BDT#UV 4KK$//!
 %!%&7!8**66u7V7VW
  !!--h.P.PQ 	  !!--l.T.TU 	 NX
@ID!!00;
 
  	3E))%0"))))??F )/66II 4U ; C C E#44HHOlN;#/#7#7L!,0@A#|n4P$QRR$$\2	3 	( &2>.D/%8J2KK#(;;T	DL0 +/',,. ""$ !.%{{*Vv*VV:;K:LMNN o
B  
	
 B%//+>?oo4/
	s   1"K8?:K= =	L5*L00L5c                    g }| j                   rg | j                  |rt        nt        }|j	                  | j                         |D cg c]  }t        |t              r|n |d        c}S c c}w )N)execution_context)r?   rA   r   r   extendr[   r   )ri   syncrA   exts       rG   get_extensionszSchema.get_extensions   sx    
??+/'5HJ 	$//* "
 c?3Ct9TT
 	
 
s   
"A/c                &    | j                  d      S )NTr{   r}   ri   s    rG   _sync_extensionszSchema._sync_extensions   s    """--    c                &    | j                  d      S )NFr   r   r   s    rG   _async_extensionszSchema._async_extensions   s    """..r   c                    t        ||      S )N)ry   rA   r   )ri   ry   rA   s      rG   create_extensions_runnerzSchema.create_extensions_runner   s     &/!
 	
r   c                Z    | j                   st        d |D         | _         | j                   S )Nc              3  B   K   | ]  }|j                         s|  y wN)_implements_resolve)rE   r|   s     rG   rH   z1Schema._get_middleware_manager.<locals>.<genexpr>   s     I#s/F/F/H#Is   )rI   r   )ri   rA   s     rG   _get_middleware_managerzSchema._get_middleware_manager   s0     ...?II/D+ ...r   c           	     &    t        || |||||      S )N)r<   schemaallowed_operationscontext
root_value	variablesprovided_operation_namer!   )ri   r<   allowed_operation_typesvariable_valuescontext_valuer   operation_names          rG   _create_execution_contextz Schema._create_execution_context   s&      6!!%$2
 	
r   c                z    || j                   j                  v r#| j                   j                  |   j                  S y r   )rO   type_map
definition)ri   names     rG   get_type_by_namezSchema.get_type_by_name  s8     4((111((11$7BBBr   c                      j                  |      }|sy t        |t              sJ t         fd|j                  D        d       S )Nc              3  r   K   | ].  }j                   j                  j                  |      k(  r| 0 y wr   )rK   name_converterget_graphql_name)rE   field
field_nameri   s     rG   rH   z,Schema.get_field_for_type.<locals>.<genexpr>.  s6      ;;-->>uES    47)r   r[   r#   nextfields)ri   r   	type_namers   s   ``  rG   get_field_for_typezSchema.get_field_for_type#  sO     %%i0%!;<<<"\\
 
 	
r   c                F     t         fd j                  D        d       S )Nc              3  r   K   | ].  }j                   j                  j                  |      k(  r| 0 y wr   )rK   r   rT   )rE   rp   graphql_nameri   s     rG   rH   z/Schema.get_directive_by_name.<locals>.<genexpr>9  s6      ;;--<<YG<W r   )r   r?   )ri   r   s   ``rG   get_directive_by_namezSchema.get_directive_by_name6  s&    !%
 
 	
r   c                    |j                   S r   )r   )ri   type_definitions     rG   rN   zSchema.get_fieldsA  s     %%%r   c           	     4  K   |t         }| j                  ||||||      }| j                         }|D ]	  }	||	_         t	        | j
                  || j                  ||      | j                  | j                  |      | j                         d {   S 7 wNr<   r   r   r   r   r   )ry   extensions_runnerprocess_errorsmiddleware_managerrJ   )
DEFAULT_ALLOWED_OPERATION_TYPESr   r}   ry   r-   r`   r   _process_errorsr   rJ   
ri   r<   r   r   r   r   r   ry   rA   	extensions
             rG   r-   zSchema.executeF  s      #*&E# ::$;+'!) ; 
 ((*
# 	<I*;I'	<LL/";;!:  //#;;JG$($@$@	
 	
 		
 	
s   BBBBc                   |t         }| j                  ||||||      }| j                  }|D ]	  }	||	_         t	        | j
                  || j                  ||      | j                  || j                  | j                  |            S )Nr   )ry   r   rJ   r   r   r   )
r   r   r   ry   r.   r`   r   rJ   r   r   r   s
             rG   r.   zSchema.execute_synci  s     #*&E# ::$;+'!) ; 
 **
# 	<I*;I'	<LL/";;!: %)$@$@$;//#;;JG

 
	
r   c           	     :  K   | j                  |t        j                  f||||      }| j                  }|D ]	  }||_         t        | j                  || j                  ||      | j                  | j                  |      | j                         d {   S 7 wr   )r   r%   SUBSCRIPTIONr   ry   r0   r`   r   r   r   rJ   )	ri   r<   r   r   r   r   ry   rA   r   s	            rG   r0   zSchema.subscribe  s      !::%2%?%?$A+'!) ; 
 ++
# 	<I*;I'	<LL/";;!:  //#;;JG$($@$@	
 	
 		
 	
s   BBBBc                   | j                   j                  j                         D ]  }|j                  }t	        |t
              s |j                  r-|j                  }t        |t        j                        sTd}|j                  D ](  }|t        j                  u r nd|j                  v s&d} n |r|j                           y )NF
resolve_idT)rO   r   valuesr   r[   r#   is_interfaceorigin
issubclassr   Node__mro____dict__resolve_id_attr)ri   concrete_typetype_defr   has_custom_resolve_idbases         rG   re   zSchema._resolve_node_ids  s    !22;;BBD 	-M$//H h(BC $$ __F&%**-(-%"NN Duzz)#t}}404- -**,9	-r   c                    ddl m | j                  j                  j	                         }d |D        }d |D        }t        fd|D              rt        j                  dt        d       y	y	)
z=Raises a warning if the schema has any federation directives.r   )FederationDirectivec              3  4   K   | ]  }|j                     y wr   )r   )rE   rs   s     rG   rH   z9Schema._warn_for_federation_directives.<locals>.<genexpr>  s     Ae))As   c              3  J   K   | ]  }|j                   xs g D ]  }|   y wr   )r?   )rE   r   rp   s      rG   rH   z9Schema._warn_for_federation_directives.<locals>.<genexpr>  s8      
&117R
  

s   !#c              3  6   K   | ]  }t        |        y wr   )r[   )rE   rp   r   s     rG   rH   z9Schema._warn_for_federation_directives.<locals>.<genexpr>  s      
;DJy"56
s   zhFederation directive found in schema. Use `strawberry.federation.Schema` instead of `strawberry.Schema`.   )
stacklevelN)	'strawberry.federation.schema_directivesr   rO   r   r   anywarningswarnUserWarning)ri   	all_typesall_type_defsall_directivesr   s       @rG   rd   z&Schema._warn_for_federation_directives  so    O))2299;	AyA
)
  
HV
 
 MMU	
r   c                    dd}| j                   j                  d   }t        t              |j                  d<   ||j                  d   _        y )Nc                R    d| j                   vry| j                   d   j                  S )Nzstrawberry-definitionF)rA   	is_one_of)objinfos     rG   _resolve_is_one_ofz8Schema._extend_introspection.<locals>._resolve_is_one_of  s'    &cnn<>>"9:DDDr   __TypeisOneOf)r   r   r   r   returnbool)r`   r   r   r   r   rY   )ri   r   instrospection_types      rG   rf   zSchema._extend_introspection  sI    	E #ll33H=0<^0L""9-8J""9-5r   c                    t        |       S r   r'   r   s    rG   as_strzSchema.as_str  s    D!!r   c                    | j                  t                     }|j                  s|j                  st	        d|j                        |j                  S )zReturn the introspection query result for the current schema.

        Raises:
            ValueError: If the introspection query fails due to an invalid schema
        zInvalid Schema. Errors )r.   r   ru   datarh   )ri   introspections     rG   
introspectzSchema.introspect  sO     ))*A*CD}'9'96}7K7K6NOPP!!!r   )	NN r   r   NNNr   )r<   r   r=   Optional[Type]r>   r   r?   zIterable[StrawberryDirective]r@   z%Iterable[Union[Type, StrawberryType]]rA   z7Iterable[Union[Type[SchemaExtension], SchemaExtension]]rJ   z'Optional[Type[GraphQLExecutionContext]]rK   zOptional[StrawberryConfig]rj   zEOptional[Dict[object, Union[Type, ScalarWrapper, ScalarDefinition]],]rQ   zIterable[object]r   None)F)r{   r   r   List[SchemaExtension])r   r   )ry   r"   rA   list[SchemaExtension]r   r   )rA   r   r   r   )NNNN)r<   Optional[str]r   zIterable[OperationType]r   Optional[Dict[str, Any]]r   Optional[Any]r   r   r   r   r   r"   )r   strr   z^Optional[Union[StrawberryObjectDefinition, ScalarDefinition, EnumDefinition, StrawberryUnion]])r   r   r   r   r   zOptional[StrawberryField])r   r   r   zOptional[StrawberryDirective])r   r#   r   zList[StrawberryField])NNNNN)r<   r   r   r   r   r   r   r   r   r   r   z!Optional[Iterable[OperationType]]r   r2   )r<   r   r   r   r   r   r   r   r   r   r   r/   )r   r   )r   r   )r   zDict[str, Any])__name__
__module____qualname__rw   r}   r   r   r   r   r   r   r   r   r   r   rN   r-   r.   r0   re   rd   rf   r   __str__r   r   r   rG   r:   r:   D   s    $('+4679NPKO-1 .0QO 	QO
 !QO %QO 2QO 5QO LQO "IQO +QO
QO ,QO  
!QOf
 . . / /
!1
?T
	
///	/ 59'+$((,

 "9
 2	

 %
 "
 &
 

& 
  

*-
	"
& 
 
&9&	& 59'+$((,EI!
!
 2!
 %	!

 "!
 &!
 "C!
 
!
L 59'+$((,EI"
"
 2"
 %	"

 ""
 &"
 "C"
 
"
N 59'+$((,

 2
 %	

 "
 &
 

>->.	K" G
"r   r:   )R
__future__r   r   	functoolsr   r   typingr   r   r   r	   r
   r   r   r   r   graphqlr   r   r   r   r   r   r   graphql.execution.middlewarer   graphql.type.directivesr   
strawberryr   strawberry.annotationr   strawberry.extensionsr    strawberry.extensions.directivesr   r   strawberry.extensions.runnerr   "strawberry.schema.schema_converterr   strawberry.schema.types.scalarr    strawberry.typesr"   strawberry.types.baser#   r$   strawberry.types.graphqlr%   printerr(    r*   r   r+   rK   r,   r-   r.   r0   r/   GraphQLExecutionContextstrawberry.directiver1   r2   r3   strawberry.types.enumr4   strawberry.types.fieldr5   strawberry.types.scalarr6   r7   strawberry.types.unionr8   QUERYMUTATIONr   r   r:   __all__r   r   rG   <module>r     s    "  0
 
 
   ; 8  6 1 @ C B - S 2 "   $ * 4C80446G6 # x"Z x"v *r   