1111from hypothesis .strategies ._internal .utils import cacheable
1212
1313from .. import nodes
14- from ..types import AstPrinter , CustomScalars , Field , InputTypeNode , InterfaceOrObject , SelectionNodes
15- from . import factories , primitives
14+ from ..types import AstPrinter , CustomScalarStrategies , Field , InputTypeNode , InterfaceOrObject , SelectionNodes
15+ from . import factories , primitives , validation
1616from .ast import make_mutation , make_query
1717from .containers import flatten
18- from .validation import maybe_parse_schema , validate_custom_scalars , validate_fields
1918
2019BY_NAME = operator .attrgetter ("name" )
2120EMPTY_LISTS_STRATEGY = st .builds (list )
@@ -45,7 +44,7 @@ class GraphQLStrategy:
4544 """Strategy for generating various GraphQL nodes."""
4645
4746 schema : graphql .GraphQLSchema = attr .ib ()
48- custom_scalars : CustomScalars = attr .ib (factory = dict )
47+ custom_scalars : CustomScalarStrategies = attr .ib (factory = dict )
4948 # As the schema is assumed to be immutable, there are a few strategy caches possible for internal components
5049 # This is a per-method cache without limits as they are proportionate to the schema size
5150 _cache : Dict [str , Dict ] = attr .ib (factory = dict )
@@ -341,13 +340,13 @@ def _make_strategy(
341340 * ,
342341 type_ : graphql .GraphQLObjectType ,
343342 fields : Optional [Iterable [str ]] = None ,
344- custom_scalars : Optional [CustomScalars ] = None ,
343+ custom_scalars : Optional [CustomScalarStrategies ] = None ,
345344) -> st .SearchStrategy [List [graphql .FieldNode ]]:
346345 if fields is not None :
347346 fields = tuple (fields )
348- validate_fields (fields , type_ .fields )
347+ validation . validate_fields (fields , type_ .fields )
349348 if custom_scalars :
350- validate_custom_scalars (custom_scalars )
349+ validation . validate_custom_scalars (custom_scalars )
351350 return GraphQLStrategy (schema , custom_scalars or {}).selections (type_ , fields = fields )
352351
353352
@@ -356,7 +355,7 @@ def queries(
356355 schema : Union [str , graphql .GraphQLSchema ],
357356 * ,
358357 fields : Optional [Iterable [str ]] = None ,
359- custom_scalars : Optional [CustomScalars ] = None ,
358+ custom_scalars : Optional [CustomScalarStrategies ] = None ,
360359 print_ast : AstPrinter = graphql .print_ast ,
361360) -> st .SearchStrategy [str ]:
362361 """A strategy for generating valid queries for the given GraphQL schema.
@@ -368,7 +367,7 @@ def queries(
368367 :param custom_scalars: Strategies for generating custom scalars.
369368 :param print_ast: A function to convert the generated AST to a string.
370369 """
371- parsed_schema = maybe_parse_schema (schema )
370+ parsed_schema = validation . maybe_parse_schema (schema )
372371 if parsed_schema .query_type is None :
373372 raise ValueError ("Query type is not defined in the schema" )
374373 return (
@@ -383,7 +382,7 @@ def mutations(
383382 schema : Union [str , graphql .GraphQLSchema ],
384383 * ,
385384 fields : Optional [Iterable [str ]] = None ,
386- custom_scalars : Optional [CustomScalars ] = None ,
385+ custom_scalars : Optional [CustomScalarStrategies ] = None ,
387386 print_ast : AstPrinter = graphql .print_ast ,
388387) -> st .SearchStrategy [str ]:
389388 """A strategy for generating valid mutations for the given GraphQL schema.
@@ -395,7 +394,7 @@ def mutations(
395394 :param custom_scalars: Strategies for generating custom scalars.
396395 :param print_ast: A function to convert the generated AST to a string.
397396 """
398- parsed_schema = maybe_parse_schema (schema )
397+ parsed_schema = validation . maybe_parse_schema (schema )
399398 if parsed_schema .mutation_type is None :
400399 raise ValueError ("Mutation type is not defined in the schema" )
401400 return (
0 commit comments