@@ -122,7 +122,7 @@ async function run(options: {
122122 validate : boolean ,
123123 quiet : boolean ,
124124 language : string ,
125- artifactDirectory ? : ?string ,
125+ artifactDirectory : ?string ,
126126} ) {
127127 const schemaPath = path . resolve ( process . cwd ( ) , options . schema ) ;
128128 if ( ! fs . existsSync ( schemaPath ) ) {
@@ -170,6 +170,13 @@ Ensure that one such file exists in ${srcDir} or its parents.
170170 languagePlugin . findGraphQLTags ,
171171 ) ;
172172
173+ const artifactDirectory = options . artifactDirectory
174+ ? // $FlowFixMe artifactDirectory can’t be null/undefined at this point
175+ path . resolve ( process . cwd ( ) , options . artifactDirectory )
176+ : null ;
177+
178+ const isGeneratedDirectory = artifactDirectory || '__generated__' ;
179+
173180 const parserConfigs = {
174181 js : {
175182 baseDir : srcDir ,
@@ -205,14 +212,10 @@ Ensure that one such file exists in ${srcDir} or its parents.
205212 } ;
206213 const writerConfigs = {
207214 js : {
208- getWriter : getRelayFileWriter (
209- srcDir ,
210- languagePlugin ,
211- options . artifactDirectory ,
212- ) ,
215+ getWriter : getRelayFileWriter ( srcDir , languagePlugin , artifactDirectory ) ,
213216 isGeneratedFile : ( filePath : string ) =>
214- filePath . endsWith ( '.' + languagePlugin . outputExtension ) &&
215- filePath . includes ( '__generated__' ) ,
217+ filePath . endsWith ( '.graphql. ' + languagePlugin . outputExtension ) &&
218+ filePath . includes ( isGeneratedDirectory ) ,
216219 parser : 'js' ,
217220 baseParsers : [ 'graphql' ] ,
218221 } ,
0 commit comments