@@ -83,6 +83,7 @@ export class GraphQLCache implements GraphQLCacheInterface {
8383 getFragmentDependencies = async (
8484 query : string ,
8585 fragmentDefinitions : ?Map < string , FragmentInfo > ,
86+ projectConfig : GraphQLProjectConfig ,
8687 ) : Promise < Array < FragmentInfo >> => {
8788 // If there isn't context for fragment references,
8889 // return an empty array.
@@ -93,7 +94,7 @@ export class GraphQLCache implements GraphQLCacheInterface {
9394 // Return an empty array.
9495 let parsedQuery ;
9596 try {
96- parsedQuery = parse ( query ) ;
97+ parsedQuery = parse ( query , projectConfig . parseOptions ) ;
9798 } catch ( error ) {
9899 return [ ] ;
99100 }
@@ -183,6 +184,7 @@ export class GraphQLCache implements GraphQLCacheInterface {
183184 getObjectTypeDependencies = async (
184185 query : string ,
185186 objectTypeDefinitions : ?Map < string , ObjectTypeInfo > ,
187+ projectConfig : GraphQLProjectConfig ,
186188 ) : Promise < Array < ObjectTypeInfo >> => {
187189 // If there isn't context for object type references,
188190 // return an empty array.
@@ -193,7 +195,7 @@ export class GraphQLCache implements GraphQLCacheInterface {
193195 // Return an empty array.
194196 let parsedQuery ;
195197 try {
196- parsedQuery = parse ( query ) ;
198+ parsedQuery = parse ( query , projectConfig . parseOptions ) ;
197199 } catch ( error ) {
198200 return [ ] ;
199201 }
@@ -320,7 +322,7 @@ export class GraphQLCache implements GraphQLCacheInterface {
320322 return ;
321323 }
322324
323- const fileAndContent = await this . promiseToReadGraphQLFile ( filePath ) ;
325+ const fileAndContent = await this . promiseToReadGraphQLFile ( filePath , projectConfig ) ;
324326 graphQLFileMap . set ( filePath , {
325327 ...fileAndContent ,
326328 size,
@@ -337,6 +339,7 @@ export class GraphQLCache implements GraphQLCacheInterface {
337339 { size, mtime} ,
338340 filePath ,
339341 exists ,
342+ projectConfig ,
340343 ) ,
341344 ) ;
342345 }
@@ -413,9 +416,10 @@ export class GraphQLCache implements GraphQLCacheInterface {
413416 metrics : { size : number , mtime : number } ,
414417 filePath : Uri ,
415418 exists : boolean ,
419+ projectConfig : GraphQLProjectConfig ,
416420 ) : Promise < Map < Uri , GraphQLFileInfo >> {
417421 const fileAndContent = exists
418- ? await this . promiseToReadGraphQLFile ( filePath )
422+ ? await this . promiseToReadGraphQLFile ( filePath , projectConfig )
419423 : null ;
420424 const graphQLFileInfo = { ...fileAndContent , ...metrics } ;
421425
@@ -438,11 +442,12 @@ export class GraphQLCache implements GraphQLCacheInterface {
438442 rootDir: Uri ,
439443 filePath : Uri ,
440444 contents : Array < CachedContent > ,
445+ projectConfig : GraphQLProjectConfig ,
441446 ) : Promise < void > {
442447 const cache = this . _fragmentDefinitionsCache . get ( rootDir ) ;
443448 const asts = contents . map ( ( { query} ) => {
444449 try {
445- return { ast : parse ( query ) , query } ;
450+ return { ast : parse ( query , projectConfig . parseOptions ) , query} ;
446451 } catch ( error ) {
447452 return { ast : null , query} ;
448453 }
@@ -475,9 +480,10 @@ export class GraphQLCache implements GraphQLCacheInterface {
475480 rootDir : Uri ,
476481 filePath : Uri ,
477482 exists : boolean ,
483+ projectConfig : GraphQLProjectConfig ,
478484 ) : Promise < void > {
479485 const fileAndContent = exists
480- ? await this . promiseToReadGraphQLFile ( filePath )
486+ ? await this . promiseToReadGraphQLFile ( filePath , projectConfig )
481487 : null ;
482488 // In the case of fragment definitions, the cache could just map the
483489 // definition name to the parsed ast, whether or not it existed
@@ -489,19 +495,20 @@ export class GraphQLCache implements GraphQLCacheInterface {
489495 cache . delete ( filePath ) ;
490496 }
491497 } else if ( fileAndContent && fileAndContent . queries ) {
492- this . updateFragmentDefinition ( rootDir , filePath , fileAndContent . queries ) ;
498+ this . updateFragmentDefinition ( rootDir , filePath , fileAndContent . queries , projectConfig ) ;
493499 }
494500 }
495501
496502 async updateObjectTypeDefinition (
497503 rootDir: Uri ,
498504 filePath : Uri ,
499505 contents : Array < CachedContent > ,
506+ projectConfig : GraphQLProjectConfig ,
500507 ) : Promise < void > {
501508 const cache = this . _typeDefinitionsCache . get ( rootDir ) ;
502509 const asts = contents . map ( ( { query} ) => {
503510 try {
504- return { ast : parse ( query ) , query } ;
511+ return { ast : parse ( query , projectConfig . parseOptions ) , query} ;
505512 } catch ( error ) {
506513 return { ast : null , query} ;
507514 }
@@ -538,6 +545,7 @@ export class GraphQLCache implements GraphQLCacheInterface {
538545 rootDir : Uri ,
539546 filePath : Uri ,
540547 exists : boolean ,
548+ projectConfig : GraphQLProjectConfig ,
541549 ) : Promise < void > {
542550 const fileAndContent = exists
543551 ? await this . promiseToReadGraphQLFile ( filePath )
@@ -623,16 +631,10 @@ export class GraphQLCache implements GraphQLCacheInterface {
623631 }
624632
625633 getSchema = async (
626- appName : ? string ,
634+ projectConfig : GraphQLProjectConfig ,
627635 queryHasExtensions ?: ?boolean = false ,
628636 ) : Promise < ?GraphQLSchema > => {
629- const projectConfig = this . _graphQLConfig . getProjectConfig ( appName ) ;
630-
631- if ( ! projectConfig ) {
632- return null ;
633- }
634-
635- const projectName = appName || 'undefinedName' ;
637+ const projectName = projectConfig . projectName || 'undefinedName' ;
636638 const schemaPath = projectConfig . schemaPath ;
637639 const endpointInfo = this . _getDefaultEndpoint ( projectConfig ) ;
638640
@@ -678,7 +680,7 @@ export class GraphQLCache implements GraphQLCacheInterface {
678680 const customDirectives = projectConfig . extensions . customDirectives ;
679681 if ( customDirectives && schema ) {
680682 const directivesSDL = customDirectives . join ( '\n\n' ) ;
681- schema = extendSchema ( schema , parse ( directivesSDL ) ) ;
683+ schema = extendSchema ( schema , parse ( directivesSDL , projectConfig . parseOptions ) ) ;
682684 }
683685
684686 if ( ! schema ) {
@@ -826,6 +828,7 @@ export class GraphQLCache implements GraphQLCacheInterface {
826828 */
827829 promiseToReadGraphQLFile = (
828830 filePath : Uri ,
831+ projectConfig : GraphQLProjectConfig ,
829832 ) : Promise < {
830833 filePath : Uri ,
831834 content : string ,
@@ -850,7 +853,7 @@ export class GraphQLCache implements GraphQLCacheInterface {
850853 return ;
851854 }
852855
853- queries . forEach ( ( { query} ) => asts . push ( parse ( query ) ) ) ;
856+ queries . forEach ( ( { query} ) => asts . push ( parse ( query , projectConfig . parseOptions ) ) ) ;
854857 } catch ( _ ) {
855858 // If query has syntax errors, go ahead and still resolve
856859 // the filePath and the content, but leave ast empty.
0 commit comments