openapi-to-graphql icon indicating copy to clipboard operation
openapi-to-graphql copied to clipboard

Cannot create property '_openAPIToGraphQL' on number

Open angrocode opened this issue 3 years ago • 9 comments

openapi-to-graphql/lib/resolver_builder.js:505
                                                element[exports.OPENAPI_TO_GRAPHQL] = {
                                                                                    ^

TypeError: Cannot create property '_openAPIToGraphQL' on number '99000006'
    at /opt/nodejs/gate_rest_graph/node_modules/openapi-to-graphql/lib/resolver_builder.js:505:85
    at Array.forEach (<anonymous>)
    at Request._callback (/opt/nodejs/gate_rest_graph/node_modules/openapi-to-graphql/lib/resolver_builder.js:503:50)
    at Request.self.callback (/opt/nodejs/gate_rest_graph/node_modules/request/request.js:185:22)
    at Request.emit (node:events:369:20)
    at Request.<anonymous> (/opt/nodejs/gate_rest_graph/node_modules/request/request.js:1154:10)
    at Request.emit (node:events:369:20)
    at IncomingMessage.<anonymous> (/opt/nodejs/gate_rest_graph/node_modules/request/request.js:1076:12)
    at Object.onceWrapper (node:events:475:28)
    at IncomingMessage.emit (node:events:381:22)

Library version 2.3.0

angrocode avatar Mar 22 '21 09:03 angrocode

@angrocode This is a very interesting error. _openAPIToGraphQL is a field that is added to API call responses to pass request/response information to other resolvers down the chain (for example in nested fields from link objects).

Can you provide a sample OAS so it is easier to debug this error?

Alan-Cha avatar Mar 22 '21 19:03 Alan-Cha

https://esi.evetech.net/latest/swagger.json It doesn't accept the whole thing because of the size You can save universe Answer in numbers /universe/systems/ /universe/regions/ ....

angrocode avatar Mar 22 '21 20:03 angrocode

Hi, I'm running into this same problem. I have an endpoint that returns an array of ints.

Here is the response from the swagger doc

"responses": {
      "200": {
          "description": "OK",
          "schema": {
              "type": "array",
              "items": {
                  "type": "integer",
                  "format": "int32"
              }
          }
      }
  }

KolbySisk avatar May 20 '21 16:05 KolbySisk

@Alan-Cha Any thoughts on the cause of this?

It seems to happen anytime I have an endpoint that returns an array of primitives.

KolbySisk avatar May 25 '21 13:05 KolbySisk

The same error with an array of primitives (in my case - string) also in @graphql-mesh/openapi

So both libs support only objects in response?

Kichrum avatar Jun 03 '21 18:06 Kichrum

@KolbySisk Sorry for the delay. I would like to take a look at this issue today. I'll let you know if I discover anything.

@Kichrum No, this library should be able to support anything in the response, primitive, objects, arrays of primitives, arrays of objects, even more complex cases like objects using oneOf (which should generate a union type).

Alan-Cha avatar Jun 04 '21 13:06 Alan-Cha

Hi, Everyone, Have you advanced with this issue? I'm facing the same problem with string arrays.

OAS:

responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  type: string
                  example: Cielo

Exception:

ERROR: uncaughtException: Cannot create property '_openAPIToGraphQL' on string 'Cielo'
TypeError: Cannot create property '_openAPIToGraphQL' on string 'Cielo'```

daniloalexandre avatar Jul 07 '21 14:07 daniloalexandre

+1

Hi @Alan-Cha, any news on that?

It looks very similar to #412 and I'm also stucked on it!

ReginaldoSantos avatar Jul 07 '21 22:07 ReginaldoSantos

@Alan-Cha Any new regarding this issue?

yondh avatar Mar 16 '23 12:03 yondh