Skip to content

Commit 00a19f7

Browse files
committed
Use a configFields array instead of lots of if conditions
1 parent f387803 commit 00a19f7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/jsonToGraphQLQuery.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { EnumType } from './types/EnumType';
22
import { VariableType } from './types/VariableType';
33

4+
export const configFields = ['__args', '__alias', '__variables', '__directives'];
5+
46
function stringify(obj_from_json: any): string {
57
if (obj_from_json instanceof EnumType) {
68
return obj_from_json.value;
@@ -48,8 +50,7 @@ function getIndent(level: number): string {
4850
}
4951

5052
function filterNonConfigFields(fieldName: string, ignoreFields: string[]) {
51-
return fieldName !== '__args' && fieldName !== '__alias' && fieldName !== '__variables'
52-
&& ignoreFields.indexOf(fieldName) == -1;
53+
return configFields.indexOf(fieldName) == -1 && ignoreFields.indexOf(fieldName) == -1;
5354
}
5455

5556
function convertQuery(node: any, level: number, output: Array<[ string, number ]>, options: IJsonToGraphQLOptions) {

0 commit comments

Comments
 (0)