@@ -4,30 +4,18 @@ use bigdecimal::{BigDecimal, ToPrimitive};
44use chrono:: prelude:: * ;
55use core:: fmt;
66use indexmap:: { IndexMap , IndexSet } ;
7- use query_structure:: { DefaultKind , PrismaValue , ValueGeneratorFn } ;
7+ use query_structure:: PrismaValue ;
88use std:: { borrow:: Cow , convert:: TryFrom , rc:: Rc , str:: FromStr } ;
99use user_facing_errors:: query_engine:: validation:: ValidationError ;
1010use uuid:: Uuid ;
1111
12- pub ( crate ) enum QueryDocumentParser {
13- WithEagerDefaultEvaluation {
14- /// NOW() default value that's reused for all NOW() defaults on a single query
15- default_now : PrismaValue ,
16- } ,
17- WithoutEagerDefaultEvaluation ,
18- }
12+ pub ( crate ) struct QueryDocumentParser ;
1913
2014type ResolveField < ' a , ' b > = & ' b dyn Fn ( & str ) -> Option < OutputField < ' a > > ;
2115
2216impl QueryDocumentParser {
23- pub ( crate ) fn with_eager_default_evaluation ( ) -> Self {
24- QueryDocumentParser :: WithEagerDefaultEvaluation {
25- default_now : crate :: request_context:: get_request_now ( ) ,
26- }
27- }
28-
29- pub ( crate ) fn without_eager_default_evaluation ( ) -> Self {
30- QueryDocumentParser :: WithoutEagerDefaultEvaluation
17+ pub ( crate ) fn new ( ) -> Self {
18+ Self
3119 }
3220
3321 // Public entry point to parsing the query document (as denoted by `selections`) against the `schema_object`.
@@ -712,20 +700,10 @@ impl QueryDocumentParser {
712700 // If it's not optional and has no default, a required field has not been provided.
713701 match & field. default_value {
714702 Some ( default_value) => {
715- let default_pv = match self {
716- Self :: WithEagerDefaultEvaluation { default_now } => match default_value {
717- DefaultKind :: Expression ( expr) if matches ! ( expr. generator( ) , ValueGeneratorFn :: Now ) => {
718- default_now. clone ( )
719- }
720- _ => default_value. get_evaluated ( ) ?,
721- } ,
722- Self :: WithoutEagerDefaultEvaluation => default_value. get ( ) ?,
723- } ;
724-
725703 match self . parse_input_value (
726704 selection_path. clone ( ) ,
727705 argument_path,
728- default_pv . into ( ) ,
706+ default_value . get ( ) ? . into ( ) ,
729707 field. field_types ( ) ,
730708 query_schema,
731709 ) {
0 commit comments