Skip to content

Commit

Permalink
feat(core): allow overriding edge name with: edge.name(...)
Browse files Browse the repository at this point in the history
  • Loading branch information
binier committed Aug 9, 2020
1 parent e55cea8 commit 98ce338
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 8 additions & 1 deletion packages/core/src/edge/edge-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,19 @@ export class EdgeBuilder extends FieldBuilder {

if (edge._autoType !== undefined) this._autoType = edge._autoType;
if (!edge.autoType) this.type = edge.type;
if (edge._name) this._name = edge._name;
Object.assign(this.directives, edge.directives);
Object.assign(this.args.all, edge.args.all);

return this;
}

/** set field name */
name(name: string) {
this._name = name;
return this;
}

get autoType() {
return this._autoType;
}
Expand Down Expand Up @@ -275,7 +282,7 @@ export class EdgeBuilder extends FieldBuilder {
A extends BuildEdgeArgs
>(args: Partial<A> = {}): Edge | Runnable {
return new Edge(
this.buildEdgeArgs(args.name || this._name || '', args.nameGen)
this.buildEdgeArgs(this._name || args.name || '', args.nameGen)
);
}

Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/query/query-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ export class QueryBuilder extends EdgeBuilder {

/** set query name */
name(name: string) {
this._name = name;
return this;
return super.name(name);
}

func(func: ArgsBuilderData['func']) {
Expand Down

0 comments on commit 98ce338

Please sign in to comment.