@@ -9,6 +9,7 @@ use std::collections::hash_map::Entry;
99use std:: collections:: HashSet ;
1010use std:: path:: Path ;
1111use std:: path:: PathBuf ;
12+ use std:: sync:: Arc ;
1213
1314use common:: Diagnostic ;
1415use common:: SourceLocationKey ;
@@ -18,13 +19,16 @@ use graphql_ir::ExecutableDefinitionName;
1819use graphql_ir:: FragmentDefinitionName ;
1920use graphql_ir:: OperationDefinitionName ;
2021use graphql_syntax:: ExecutableDefinition ;
22+ use relay_config:: ProjectConfig ;
2123use relay_config:: ProjectName ;
2224
2325use crate :: artifact_map:: ArtifactSourceKey ;
2426use crate :: compiler_state:: GraphQLSources ;
27+ use crate :: config:: Config ;
2528use crate :: errors:: Error ;
2629use crate :: errors:: Result ;
2730use crate :: file_source:: LocatedGraphQLSource ;
31+ use crate :: utils:: get_parser_features;
2832
2933#[ derive( Debug ) ]
3034pub struct GraphQLAsts {
@@ -50,10 +54,13 @@ impl GraphQLAsts {
5054 pub fn from_graphql_sources_map (
5155 graphql_sources_map : & FnvHashMap < ProjectName , GraphQLSources > ,
5256 dirty_artifact_sources : & FnvHashMap < ProjectName , Vec < ArtifactSourceKey > > ,
57+ config : & Arc < Config > ,
5358 ) -> Result < FnvHashMap < ProjectName , GraphQLAsts > > {
5459 graphql_sources_map
5560 . iter ( )
5661 . map ( |( & project_name, sources) | {
62+ let project_config = & config. projects [ & project_name] ;
63+
5764 let asts = GraphQLAsts :: from_graphql_sources (
5865 sources,
5966 dirty_artifact_sources
@@ -73,6 +80,7 @@ impl GraphQLAsts {
7380 } )
7481 . collect ( )
7582 } ) ,
83+ project_config,
7684 ) ?;
7785 Ok ( ( project_name, asts) )
7886 } )
@@ -85,7 +93,10 @@ impl GraphQLAsts {
8593 pub fn from_graphql_sources (
8694 graphql_sources : & GraphQLSources ,
8795 dirty_definitions : Option < Vec < & ExecutableDefinitionName > > ,
96+ project_config : & ProjectConfig ,
8897 ) -> Result < Self > {
98+ let parser_features = get_parser_features ( project_config) ;
99+
89100 let mut syntax_errors = Vec :: new ( ) ;
90101
91102 let mut asts: FnvHashMap < PathBuf , Vec < ExecutableDefinition > > = Default :: default ( ) ;
@@ -108,9 +119,10 @@ impl GraphQLAsts {
108119 {
109120 let source_location =
110121 SourceLocationKey :: embedded ( & file_name. to_string_lossy ( ) , * index) ;
111- match graphql_syntax:: parse_executable (
122+ match graphql_syntax:: parse_executable_with_features (
112123 & graphql_source. text_source ( ) . text ,
113124 source_location,
125+ parser_features,
114126 ) {
115127 Ok ( document) => {
116128 for def in & document. definitions {
@@ -145,9 +157,10 @@ impl GraphQLAsts {
145157 // TODO: parse name instead of the whole graphql text
146158 let source_location =
147159 SourceLocationKey :: embedded ( & file_name. to_string_lossy ( ) , * index) ;
148- if let Ok ( document) = graphql_syntax:: parse_executable (
160+ if let Ok ( document) = graphql_syntax:: parse_executable_with_features (
149161 & graphql_source. text_source ( ) . text ,
150162 source_location,
163+ parser_features,
151164 ) {
152165 for def in document. definitions {
153166 match def {
@@ -210,9 +223,10 @@ impl GraphQLAsts {
210223 {
211224 let source_location =
212225 SourceLocationKey :: embedded ( & file_name. to_string_lossy ( ) , * index) ;
213- match graphql_syntax:: parse_executable (
226+ match graphql_syntax:: parse_executable_with_features (
214227 & graphql_source. text_source ( ) . text ,
215228 source_location,
229+ parser_features,
216230 ) {
217231 Ok ( document) => {
218232 definitions_for_file. extend ( document. definitions ) ;
0 commit comments