Skip to content

Commit c5f27da

Browse files
author
Rax
committed
Fixed root resolver issue + updated libs versions
1 parent 4d1dad8 commit c5f27da

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

lib/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ const build = (swaggerPath) => {
2020
}
2121
return queryFields;
2222
}
23-
})
23+
}),
24+
resolve: () => 'Without this resolver graphql does not resolve further'
2425
}
2526
})
2627
});

lib/type_map.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function createGQLObject(jsonSchema, title, isInputType) {
5757
if (isObjectType(jsonSchema.items)) {
5858
return new graphql.GraphQLList(createGQLObject(jsonSchema.items, title + '_items', isInputType));
5959
} else {
60-
return new graphql.GraphQLList(getPrimitiveTypes(jsonSchema.items.type));
60+
return new graphql.GraphQLList(getPrimitiveTypes(jsonSchema.items));
6161
}
6262
}
6363

@@ -93,14 +93,19 @@ function jsonSchemaTypeToGraphQL(title, jsonSchema, schemaName, isInputType) {
9393
if (isObjectType(jsonSchema)) {
9494
return createGQLObject(jsonSchema, title + '_' + schemaName, isInputType);
9595
} else if (jsonSchema.type) {
96-
return getPrimitiveTypes(jsonSchema.type);
96+
return getPrimitiveTypes(jsonSchema);
9797
} else {
9898
throw new Error("Don't know how to handle schema " + JSON.stringify(jsonSchema) + " without type and schema");
9999
}
100100
}
101101

102-
function getPrimitiveTypes(jsonSchemaType) {
103-
const type = primitiveTypes[jsonSchemaType];
102+
function getPrimitiveTypes(jsonSchema) {
103+
let jsonType = jsonSchema.type;
104+
const format = jsonSchema.format;
105+
if (format === 'int64') {
106+
jsonType = 'string';
107+
}
108+
const type = primitiveTypes[jsonType];
104109
if (!type) {
105110
throw new Error(`Cannot build primitive type "${jsonSchemaType}"`);
106111
}

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "swagger-to-graphql",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "",
55
"main": "lib/index.js",
66
"scripts": {
@@ -14,10 +14,10 @@
1414
"author": "Roman Krivtsov",
1515
"license": "MIT",
1616
"dependencies": {
17-
"graphql": "^0.7.1",
17+
"graphql": "^0.8.2",
1818
"json-schema-ref-parser": "^3.1.2",
1919
"lodash": "^4.16.4",
20-
"node-request-by-swagger": "^1.0.0",
20+
"node-request-by-swagger": "^1.0.5",
2121
"request": "^2.75.0",
2222
"request-promise": "^4.1.1"
2323
},

0 commit comments

Comments
 (0)