Skip to content

Commit 0e1255b

Browse files
author
Alban Bailly
committed
a bit more cleanup and fix undefined var
1 parent 034aa1f commit 0e1255b

File tree

2 files changed

+24
-71
lines changed

2 files changed

+24
-71
lines changed

generateQuery.js

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,30 @@
1-
const printName = (name) => {
2-
return ' ' + name;
3-
}
1+
const printName = name => {
2+
return " " + name;
3+
};
44

55
const handleNested = (fieldsPath, fieldType) => {
66
const fields = recursiveQuery(fieldsPath);
7-
return fields
8-
? ` ${fieldType} { ${fields} }`
9-
: '';
10-
}
7+
return fields ? ` ${fieldType} { ${fields} }` : "";
8+
};
119

1210
const _query = property => {
1311
// Special cases (nested values)
14-
if (property.name === 'allOf') {
12+
if (property.name === "allOf") {
1513
if (property.type.ofType) {
16-
return handleNested(property.type.ofType.fields, 'allOf');
14+
return handleNested(property.type.ofType.fields, "allOf");
1715
}
1816

19-
return handleNested(property.type.fields, 'allOf');
17+
return handleNested(property.type.fields, "allOf");
2018
}
2119

22-
if (property.name === 'oneOf') {
20+
if (property.name === "oneOf") {
2321
if (property.type.ofType) {
24-
return handleNested(property.type.ofType.fields, 'oneOf');
22+
return handleNested(property.type.ofType.fields, "oneOf");
2523
}
26-
return handleNested(property.type.fields, 'oneOf');
24+
return handleNested(property.type.fields, "oneOf");
2725
}
2826

2927
// Base cases
30-
3128
if (!property.type) {
3229
return printName(property.name);
3330
}
@@ -38,22 +35,27 @@ const _query = property => {
3835
}
3936

4037
// Normal recursion
41-
4238
if (property.type && property.type.fields) {
43-
return `${printName(property.name)} { ${recursiveQuery(property.type.fields)} }`;
39+
return `${printName(property.name)} { ${recursiveQuery(
40+
property.type.fields
41+
)} }`;
4442
}
4543

4644
if (property.type && property.type.typeOf && property.type.typeOf.fields) {
47-
return `${printName(property.name)} { ${recursiveQuery(property.type.typeOf.fields)} }`;
45+
return `${printName(property.name)} { ${recursiveQuery(
46+
property.type.typeOf.fields
47+
)} }`;
4848
}
4949

5050
// If we reach this point, there's a problem.
51-
throw new Error('No cases matched.');
52-
}
51+
throw new Error("No cases matched.");
52+
};
5353

5454
const recursiveQuery = properties => {
55-
if (properties === null) { return; }
55+
if (properties === null) {
56+
return;
57+
}
5658
return properties.map(property => _query(property));
57-
}
59+
};
5860

59-
module.exports = { rawQuery, recursiveQuery };
61+
module.exports = { recursiveQuery };

src/components/0_fragments/fragmentGenerator.js

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)