Skip to content

Commit

Permalink
Add the ability to override Single/List fields resolvers
Browse files Browse the repository at this point in the history
  • Loading branch information
firassziedan committed Jan 15, 2023
1 parent 855e18e commit 6b21bc5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/SchemaBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ class SchemaBuilder {
}

_rootSingleField(modelData) {
if (modelData.modelClass.hasOwnProperty('getSingleNode')) {
return modelData.modelClass.getSingleNode
}

return {
type: this._typeForModel(modelData),
args: modelData.args,
Expand All @@ -194,6 +198,10 @@ class SchemaBuilder {
}

_rootListField(modelData) {
if (modelData.modelClass.hasOwnProperty('getListNode')) {
return modelData.modelClass.getListNode
}

return {
type: new GraphQLList(this._typeForModel(modelData)),
args: modelData.args,
Expand Down

0 comments on commit 6b21bc5

Please sign in to comment.