Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dynamic output property #205

Merged
merged 9 commits into from
Aug 26, 2019
20 changes: 11 additions & 9 deletions src/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1149,15 +1149,17 @@ export class SchemaBuilder {
return this.addDynamicScalar(methodName, val, block);
}
// @ts-ignore
block[methodName] = (...args: any[]) => {
const config = isList ? [args[0], { list: isList, ...args[1] }] : args;
jasonkuhrt marked this conversation as resolved.
Show resolved Hide resolved
return val.value.factory({
args: config,
typeDef: block,
builder: this,
typeName: block.typeName,
});
};
Object.defineProperty(block, methodName, {
jasonkuhrt marked this conversation as resolved.
Show resolved Hide resolved
get() {
return val.value.factory({
args: [],
typeDef: block,
builder: this,
typeName: block.typeName,
})
},
enumerable: true,
})
});
}

Expand Down