UNPKG

693 BJavaScriptView Raw
1/**
2 * Copyright (c) Facebook, Inc. and its affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 * strict-local
8 * @format
9 */
10'use strict';
11
12function parseFile(baseDir, file) {
13 var text = require("fs").readFileSync(require("path").join(baseDir, file.relPath), 'utf8');
14
15 return require("graphql").parse(new (require("graphql").Source)(text, file.relPath), {
16 experimentalFragmentVariables: true
17 });
18}
19
20function getParser(baseDir) {
21 return new (require("./ASTCache"))({
22 baseDir: baseDir,
23 parse: parseFile
24 });
25}
26
27module.exports = {
28 parseFile: parseFile,
29 getParser: getParser
30};
\No newline at end of file