Skip to content
This repository was archived by the owner on Jan 4, 2020. It is now read-only.

Commit 119687a

Browse files
committed
bugfix for multi version graphql compatibility
1 parent f6a9784 commit 119687a

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,9 @@ var GraphQLFactoryBaseBackend = function () {
607607
}, {
608608
key: 'isNested',
609609
value: function isNested(info) {
610-
return _.get(info, 'path', []).length > 1;
610+
// support for current and previous graphql info objects
611+
var infoPath = _.get(info, 'path', []);
612+
return _.isArray(infoPath) ? infoPath.length > 1 : infoPath.prev !== undefined;
611613
}
612614

613615
// get parent type
@@ -623,7 +625,9 @@ var GraphQLFactoryBaseBackend = function () {
623625
}, {
624626
key: 'getCurrentPath',
625627
value: function getCurrentPath(info) {
626-
return _.last(_.get(info, 'path'));
628+
// support for current and previous graphql info objects
629+
var infoPath = _.get(info, 'path');
630+
return _.isArray(infoPath) ? _.last(infoPath) : infoPath.key;
627631
}
628632

629633
// get type definition

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "graphql-factory-backend",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "Backend plugin for graphql-factory",
55
"license": "MIT",
66
"main": "index.js",

src/base/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ export class GraphQLFactoryBaseBackend {
150150

151151
// determine if the resolve is nested
152152
isNested (info) {
153-
return _.get(info, 'path', []).length > 1
153+
// support for current and previous graphql info objects
154+
let infoPath = _.get(info, 'path', [])
155+
return _.isArray(infoPath) ? infoPath.length > 1 : infoPath.prev !== undefined
154156
}
155157

156158
// get parent type
@@ -160,7 +162,9 @@ export class GraphQLFactoryBaseBackend {
160162

161163
// current path
162164
getCurrentPath (info) {
163-
return _.last(_.get(info, 'path'))
165+
// support for current and previous graphql info objects
166+
let infoPath = _.get(info, 'path')
167+
return _.isArray(infoPath) ? _.last(infoPath) : infoPath.key
164168
}
165169

166170
// get type definition

0 commit comments

Comments
 (0)