File tree 3 files changed +28
-1
lines changed
3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change
1
+ # import * from "shared"
2
+
3
+ type A {
4
+ first : String
5
+ second : Shared
6
+ }
Original file line number Diff line number Diff line change @@ -572,6 +572,25 @@ input PostFilter {
572
572
t . is ( actualSDL , expectedSDL )
573
573
} )
574
574
575
+ test ( 'global schema modules' , t => {
576
+ const shared = `
577
+ type Shared {
578
+ first: String
579
+ }
580
+ `
581
+ const expectedSDL = `\
582
+ type A {
583
+ first: String
584
+ second: Shared
585
+ }
586
+
587
+ type Shared {
588
+ first: String
589
+ }
590
+ `
591
+ t . is ( importSchema ( 'fixtures/global/a.graphql' , { shared } ) , expectedSDL )
592
+ } )
593
+
575
594
test ( 'missing type on type' , t => {
576
595
const err = t . throws ( ( ) => importSchema ( 'fixtures/type-not-found/a.graphql' ) , Error )
577
596
t . is ( err . message , `Field test: Couldn't find type Post in any of the schemas.` )
Original file line number Diff line number Diff line change @@ -197,7 +197,9 @@ function collectDefinitions(
197
197
// Process each file (recursively)
198
198
rawModules . forEach ( m => {
199
199
// If it was not yet processed (in case of circular dependencies)
200
- const moduleFilePath = isFile ( filePath ) ? path . resolve ( path . join ( dirname , m . from ) ) : m . from
200
+ const moduleFilePath = isFile ( filePath ) && isFile ( m . from )
201
+ ? path . resolve ( path . join ( dirname , m . from ) )
202
+ : m . from
201
203
if ( ! processedFiles . has ( moduleFilePath ) ) {
202
204
collectDefinitions (
203
205
m . imports ,
You can’t perform that action at this time.
0 commit comments