/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @flow
 * @format
 */

'use strict';

const fs = require('fs');
const path = require('path');

const {SCHEMA_EXTENSION} = require('./GraphQLRelayDirective');
const {parse} = require('graphql');

function getSchemaIntrospection(schemaPath: string, basePath: ?string) {
  try {
    let fullSchemaPath = schemaPath;
    if (!fs.existsSync(fullSchemaPath) && basePath) {
      fullSchemaPath = path.join(basePath, schemaPath);
    }
    const source = fs.readFileSync(fullSchemaPath, 'utf8');
    if (source[0] === '{') {
      return JSON.parse(source);
    }
    return parse(SCHEMA_EXTENSION + '\n' + source);
  } catch (error) {
    // Log a more helpful warning (by including the schema path).
    console.error(
      'Encountered the following error while loading the GraphQL schema: ' +
        schemaPath +
        '\n\n' +
        error.stack
          .split('\n')
          .map(line => '> ' + line)
          .join('\n'),
    );
    throw error;
  }
}

module.exports = getSchemaIntrospection;

@@ -378,16 +378,267 @@
 hql');%0A%0A
+function readSource(sourceFile: string, basePath: ?string): string %7B%0A  const fullSourceFile =%0A    !fs.existsSync(sourceFile) && basePath%0A      ? path.join(basePath, sourceFile)%0A      : sourceFile;%0A%0A  return fs.readFileSync(fullSourceFile, 'utf8');%0A%7D%0A%0A
 function
@@ -718,17 +718,15 @@
     
-let fullS
+const s
 chem
@@ -730,16 +730,17 @@
 hemaPath
+s
  = schem
@@ -748,117 +748,199 @@
 Path
-;%0A    if (!fs.existsSync(fullSchemaPath) && basePath) %7B%0A      fullSchemaPath = path.join(basePath, schemaPath
+.split(',');%0A    if (schemaPaths.length %3E 1) %7B%0A      return parse(%0A        SCHEMA_EXTENSION +%0A          '%5Cn' +%0A          schemaPaths.map(file =%3E readSource(file, basePath)).join('%5Cn'),%0A      
 );%0A 
@@ -940,24 +940,25 @@
    );%0A    %7D%0A
+%0A
     const so
@@ -964,37 +964,28 @@
 ource = 
-fs.
 read
-FileSync(fullS
+Source(s
 chemaPat
@@ -987,22 +987,24 @@
 maPath, 
-'utf8'
+basePath
 );%0A    i

Support for multiple schema path in getSchemaIntrospection