Skip to content

Commit

Permalink
fix(ElasticApiParser): Add elasticApiFilesPath option
Browse files Browse the repository at this point in the history
  • Loading branch information
nodkz committed Mar 7, 2017
1 parent 4e5a370 commit 9963b9c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/ElasticApiParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export type ElasticApiParserOptsT = {
| '1_0'
| '0_90',
prefix?: string,
elasticApiFilesPath?: string,
};

export type ElasticParamConfigT = {
Expand All @@ -63,26 +64,26 @@ export type ElasticCaSettingsT = {
urls?: ElasticCaSettingsUrlT[],
};

export const elasticApiFilesPath = './node_modules/elasticsearch/src/lib/apis/';

export default class ElasticApiParser {
cachedEnums: {
[fieldName: string]: { [valsStringified: string]: GraphQLEnumType },
};
version: string;
prefix: string;
elasticApiFilesPath: string;

constructor(opts: ElasticApiParserOptsT = {}) {
// derived from installed package `elasticsearch`
// from ../../node_modules/elasticsearch/src/lib/apis/VERSION.js
this.version = opts.version || '5_0';
this.prefix = opts.prefix || 'Elastic';
this.elasticApiFilesPath = opts.elasticApiFilesPath || './node_modules/elasticsearch/src/lib/apis/';
this.cachedEnums = {};
}

run() {
this.cachedEnums = {};
const apiFilePath = path.resolve(elasticApiFilesPath, `${this.version}.js`);
const apiFilePath = path.resolve(this.elasticApiFilesPath, `${this.version}.js`);
const source = this.loadApiFile(apiFilePath);
return this.parseSource(source);
}
Expand Down

0 comments on commit 9963b9c

Please sign in to comment.