swagger-to-graphql
swagger-to-graphql copied to clipboard
Class constructor GraphQLNonNull cannot be invoked without 'new'
There was such a problem, the swager scheme did not change, everything worked before
`yaml openapi: 3.0.1 info: title: restaurant description: This is a restaurant api description termsOfService: http://swagger.io/terms/ version: 1.0.0 servers:
- url: https://localhost:3000/api tags:
- name: Drink description: Drink
- name: Food description: Food
- name: Menu description: Menu paths: /foods: get: tags: - Food summary: Get all foods operationId: foods responses: 200: description: successful operation content: application/json: schema: type: array items: $ref: '#/components/schemas/Food' 401: $ref: '#/components/schemas/401' 403: $ref: '#/components/schemas/403' 404: $ref: '#/components/schemas/404' 405: $ref: '#/components/schemas/405' 415: $ref: '#/components/schemas/415' 500: $ref: '#/components/schemas/500' /food: post: tags: - Food summary: Create new food operationId: createFood description: Create new food requestBody: content: application/json: schema: $ref: '#/components/schemas/FoodPostCreate' required: true responses: 201: description: OK content: application/json: schema: $ref: '#/components/schemas/Food' 401: $ref: '#/components/schemas/401' 403: $ref: '#/components/schemas/403' 404: $ref: '#/components/schemas/404' 405: $ref: '#/components/schemas/405' 415: $ref: '#/components/schemas/415' 500: $ref: '#/components/schemas/500' patch: tags: - Food description: Update food by id operationId: updateFood requestBody: content: application/json: schema: $ref: '#/components/schemas/FoodPostUpdate' responses: 200: description: OK content: application/json: schema: $ref: '#/components/schemas/Food' 400: $ref: '#/components/schemas/400' 401: $ref: '#/components/schemas/401' 405: $ref: '#/components/schemas/405' 415: $ref: '#/components/schemas/415' 500: $ref: '#/components/schemas/500' delete: tags: - Food description: Delete food by id operationId: deleteFood requestBody: content: application/json: schema: type: object properties: id: type: number responses: 200: description: OK content: application/json: schema: $ref: '#/components/schemas/Food' 400: $ref: '#/components/schemas/400' 401: $ref: '#/components/schemas/401' 405: $ref: '#/components/schemas/405' 415: $ref: '#/components/schemas/415' 500: $ref: '#/components/schemas/500' /food/{id}: get: tags: - Food summary: Get food by d operationId: food parameters: - name: id in: path description: Food id required: true schema: type: number responses: 201: description: OK content: application/json: schema: $ref: '#/components/schemas/Food' 401: $ref: '#/components/schemas/401' 403: $ref: '#/components/schemas/403' 404: $ref: '#/components/schemas/404' 405: $ref: '#/components/schemas/405' 415: $ref: '#/components/schemas/415' 500: $ref: '#/components/schemas/500' components: schemas: Food: type: object required: ['id', 'name', 'vegan'] properties: id: type: integer name: type: string vegan: type: string FoodPostCreate: type: object required: ['name', 'vegan'] properties: name: type: string vegan: type: string FoodPostUpdate: type: object required: ['id'] properties: id: type: number name: type: string vegan: type: string 201: description: Created 204: description: No Content 400: description: Bad Request 401: description: Unauthorized 403: description: Forbidden 404: description: Not Found 405: description: Method not allowed 409: description: Conflict 415: description: Unsupported media type 500: description: Internal server error `
Error:
TypeError: Class constructor GraphQLNonNull cannot be invoked without 'new'
at Object.exports.createGraphQLType (/home/poltoratchi/my/graphql/node_modules/swagger-to-graphql/lib/typeMap.js:115:56)
at /home/poltoratchi/my/graphql/node_modules/swagger-to-graphql/lib/typeMap.js:46:28
at Object.exports.jsonSchemaTypeToGraphQL (/home/poltoratchi/my/graphql/node_modules/swagger-to-graphql/lib/typeMap.js:60:7)
at /home/poltoratchi/my/graphql/node_modules/swagger-to-graphql/lib/index.js:78:30
at Array.reduce (swagger-to-graphql --swagger-schema ./docs/api.swagger.yaml > docs/schema.gql
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the root@ schema script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in: npm ERR! /home/poltoratchi/.npm/_logs/2022-08-22T07_59_13_470Z-debug.log