yarax / swagger-to-graphql

Swagger to GraphQL API adapter
MIT License
924 stars 150 forks source link

Throws an exception on the certain Swagger json's #159

Open ravishchawla opened 4 years ago

ravishchawla commented 4 years ago

I get an exception on a Open API Swagger JSON that I ran the plugin through, the error is unexplainable because there are no pointers to file locations for it:

I'm using the JIRA v2. API's, located here: https://developer.atlassian.com/cloud/jira/platform/rest/v2/ To try and narrow down the issue, I modified the original Swagger JSON available to only include 4 endpoints and their schemas: https://gist.github.com/ravishchawla/3ee42fb73878dd36bf30b210b6680f36

I get this exception when running the swagger-to-graphql plugin on either of those two JSON's (NPM version 6.13.1):

TypeError: Cannot call a class as a function
    at _classCallCheck (/home/chawlar/workspace/usergraph/apollo-server/node_modules/graphql/type/definition.js:47:99)
    at Object.GraphQLNonNull (/home/chawlar/workspace/usergraph/apollo-server/node_modules/graphql/type/definition.js:777:5)
    at Object.exports.createGraphQLType (/home/chawlar/workspace/usergraph/apollo-server/node_modules/swagger-to-graphql/lib/typeMap.js:115:56)
    at /home/chawlar/workspace/usergraph/apollo-server/node_modules/swagger-to-graphql/lib/typeMap.js:46:28
    at Object.exports.jsonSchemaTypeToGraphQL (/home/chawlar/workspace/usergraph/apollo-server/node_modules/swagger-to-graphql/lib/typeMap.js:60:7)
    at /home/chawlar/workspace/usergraph/apollo-server/node_modules/swagger-to-graphql/lib/index.js:78:30
    at Array.reduce (<anonymous>)
    at getFields (/home/chawlar/workspace/usergraph/apollo-server/node_modules/swagger-to-graphql/lib/index.js:75:10)
    at schemaFromEndpoints (/home/chawlar/workspace/usergraph/apollo-server/node_modules/swagger-to-graphql/lib/index.js:104:23)
    at Object.<anonymous> (/home/chawlar/workspace/usergraph/apollo-server/node_modules/swagger-to-graphql/lib/index.js:133:39)