Skip to content

Commit 965e679

Browse files
authored
Merge pull request #370 from smartive/next
break: Do not generate __typename
2 parents 651632e + 05be9e9 commit 965e679

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/bin/gqm/codegen.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ export const generateGraphqlClientTypes = async () => {
3636
config: {
3737
preResolveTypes: true, // Simplifies the generated types
3838
namingConvention: 'keep', // Keeps naming as-is
39-
nonOptionalTypename: true, // Forces `__typename` on all selection sets
40-
skipTypeNameForRoot: true, // Don't generate __typename for root types
39+
skipTypename: true, // Don't generate __typename
4140
avoidOptionals: {
4241
// Avoids optionals on the level of the field
4342
field: true,

src/resolvers/resolver.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,13 @@ const applySubQueries = async (
153153
const children = hydrate(subNode, rawChildren);
154154

155155
for (const child of children) {
156+
const childClone = cloneDeep(child);
156157
for (const entry of entriesById[child[foreignKey] as string]) {
158+
childClone.PARENT = entry;
157159
if (isList) {
158-
(entry[fieldName] as Entry[]).push(cloneDeep(child));
160+
(entry[fieldName] as Entry[]).push(childClone);
159161
} else {
160-
entry[fieldName] = cloneDeep(child);
162+
entry[fieldName] = childClone;
161163
}
162164
}
163165
}

src/resolvers/utils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,13 @@ export function hydrate<T extends Entry>(
8888
continue outer;
8989
}
9090
}
91-
current[part] = {};
91+
current[part] = {
92+
PARENT: current,
93+
};
9294
}
9395
current = current[part];
9496
}
97+
9598
current[it(fieldName)] = value;
9699
}
97100

0 commit comments

Comments
 (0)