Skip to content

Commit

Permalink
fix duplicate interfaces when building schema multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
hayes committed Mar 1, 2023
1 parent 35f5c58 commit f225955
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/eighty-feet-sparkle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@pothos/core': patch
---

Fix duplicate interfaces when building a schema multiple times
8 changes: 6 additions & 2 deletions packages/core/src/config-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,12 @@ export default class ConfigStore<Types extends SchemaTypes> {
this.pending = false;

const fns = this.addFieldFns;
const interfaces = this.pendingInterfaces;
const unions = this.pendingUnionTypes;

this.addFieldFns = [];
this.pendingInterfaces = new Map();
this.pendingUnionTypes = new Map();

fns.forEach((fn) => void fn());

Expand All @@ -456,13 +460,13 @@ export default class ConfigStore<Types extends SchemaTypes> {
);
}

for (const [typeName, unionFns] of this.pendingUnionTypes) {
for (const [typeName, unionFns] of unions) {
for (const fn of unionFns) {
this.addUnionTypes(typeName, fn);
}
}

for (const [typeName, interfacesFns] of this.pendingInterfaces) {
for (const [typeName, interfacesFns] of interfaces) {
for (const fn of interfacesFns) {
this.addInterfaces(typeName, fn);
}
Expand Down

0 comments on commit f225955

Please sign in to comment.