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

Commit a5ff06a

Browse files
committed
* fixing bug where recursive calls to parseLiteral were not bound
1 parent 404848b commit a5ff06a

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ function identity(value) {
5757
}
5858

5959
function parseLiteral(ast) {
60+
var boundParseLiteral = parseLiteral.bind(this);
6061
var Kind = this.graphql.Kind;
6162

6263
switch (ast.kind) {
@@ -71,7 +72,7 @@ function parseLiteral(ast) {
7172
var _ret = function () {
7273
var value = Object.create(null);
7374
ast.fields.forEach(function (field) {
74-
value[field.name.value] = parseLiteral(field.value);
75+
value[field.name.value] = boundParseLiteral(field.value);
7576
});
7677
return {
7778
v: value
@@ -81,7 +82,7 @@ function parseLiteral(ast) {
8182
if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v;
8283
}
8384
case Kind.LIST:
84-
return ast.values.map(parseLiteral);
85+
return ast.values.map(boundParseLiteral);
8586
default:
8687
return null;
8788
}

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-types",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "Custom types plugin for graphql-factory",
55
"license": "MIT",
66
"main": "index.js",

src/types/FactoryJSON.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ function identity(value) {
77
}
88

99
function parseLiteral (ast) {
10+
let boundParseLiteral = parseLiteral.bind(this)
1011
let { Kind } = this.graphql
1112
switch (ast.kind) {
1213
case Kind.STRING:
@@ -18,12 +19,12 @@ function parseLiteral (ast) {
1819
case Kind.OBJECT: {
1920
const value = Object.create(null)
2021
ast.fields.forEach(field => {
21-
value[field.name.value] = parseLiteral(field.value)
22+
value[field.name.value] = boundParseLiteral(field.value)
2223
})
2324
return value
2425
}
2526
case Kind.LIST:
26-
return ast.values.map(parseLiteral)
27+
return ast.values.map(boundParseLiteral)
2728
default:
2829
return null
2930
}

0 commit comments

Comments
 (0)