1010from hypothesis .errors import InvalidArgument
1111from hypothesis .strategies ._internal .utils import cacheable
1212
13+ from .. import nodes
1314from ..types import AstPrinter , CustomScalars , Field , InputTypeNode , InterfaceOrObject , SelectionNodes
1415from . import factories , primitives
1516from .ast import make_mutation , make_query
@@ -80,7 +81,7 @@ def values(self, type_: graphql.GraphQLInputType) -> st.SearchStrategy[InputType
8081 def lists (self , type_ : graphql .GraphQLList , nullable : bool = True ) -> st .SearchStrategy [graphql .ListValueNode ]:
8182 """Generate a `graphql.ListValueNode`."""
8283 strategy = st .lists (self .values (type_ .of_type ))
83- return primitives .maybe_null (strategy .map (factories . list_value ), nullable )
84+ return primitives .maybe_null (strategy .map (nodes . List ), nullable )
8485
8586 @instance_cache (lambda type_ , nullable = True : (type_ .name , nullable ))
8687 def objects (
@@ -89,7 +90,7 @@ def objects(
8990 """Generate a `graphql.ObjectValueNode`."""
9091 fields = {name : field for name , field in type_ .fields .items () if self .can_generate_field (field )}
9192 strategy = subset_of_fields (fields , force_required = True ).flatmap (self .lists_of_object_fields )
92- return primitives .maybe_null (strategy .map (factories . object_value ), nullable )
93+ return primitives .maybe_null (strategy .map (nodes . Object ), nullable )
9394
9495 def can_generate_field (self , field : graphql .GraphQLInputField ) -> bool :
9596 """Whether it is possible to generate values for the given field."""
@@ -199,11 +200,7 @@ def inner(draw: Any) -> List[graphql.ArgumentNode]:
199200 if not isinstance (argument .type , graphql .GraphQLNonNull ):
200201 # If the type is nullable, then either generate `null` or skip it completely
201202 if draw (st .booleans ()):
202- args .append (
203- graphql .ArgumentNode (
204- name = graphql .NameNode (value = name ), value = primitives .NULL_VALUE_NODE
205- )
206- )
203+ args .append (graphql .ArgumentNode (name = graphql .NameNode (value = name ), value = nodes .Null ))
207204 continue
208205 raise
209206 args .append (draw (argument_strategy .map (factories .argument (name ))))
0 commit comments