Objects without prototypes are causing errors in body request. #5643
Unanswered
gabrielferreiraa
asked this question in
Ideas
Replies: 1 comment
-
Is that the same as #5070 ? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi guys. Can you help me to understand if this behavior is a bug or not?
Here, is this line -> https://github.com/apollographql/apollo-server/blob/main/packages/apollo-datasource-rest/src/RESTDataSource.ts#L235
We have one validation to check if my body is
object
or anarray
. Right?But, this object validation in my view, its wrong. Because, not all objects in Javascript has
Object
as constructor/prototype.E.g:
Object.create
doesn't have a constructor -> http://adripofjavascript.com/blog/drips/creating-objects-without-prototypes.htmlIn some cases, when you get your body request payload and put directly in your body (
this.post('/url', data)
) we have some errors... to bypass this error we need construct an object with constructor, like a :this.post('/url', { ...data }
To resolve this, in my fork, I modified this line and wrote this
With that, we guarantee that any object will work in body request.
Beta Was this translation helpful? Give feedback.
All reactions