Skip to content

Conversation

oojacoboo
Copy link
Collaborator

GraphQL won't parse the request body payload for GraphQL JSON. Additionally, it won't fetch the schema as is typically handled through common GraphQL clients.

GraphQL won't parse the request body payload for GraphQL JSON.  Additionally, it won't fetch the schema as is typically handled through common GraphQL clients.
@moufmouf
Copy link
Member

moufmouf commented Nov 8, 2019

Hey Jacob,

Actually, the current code is correct.

I think you are mixing up "getParsedBody" and "getBody". PSR-7 provides both, and there is this strange state where a request can have a "body", and no "parsed body" (because no middleware cared enough to json_decode the body). So this code is useful if no middleware added a "parsedBody" to the request (in which case we add one).

I'm closing this issue. I guess you opened this PR because you faced some kind of real problem. Don't hesitate to open a new issue if you are still facing a problem.

@moufmouf moufmouf closed this Nov 8, 2019
@oojacoboo
Copy link
Collaborator Author

oojacoboo commented Nov 10, 2019

Hey David, makes sense. I guess the issue here is that parsedBody is an empty array and not null in my case. I'm pulling this value directly from the Zend\Diactoros\ServerRequest.

$serverRequestFactory = [ServerRequestFactory::class, 'fromGlobals'];
debug(($serverRequestFactory)()); //debug() is just a little function for dumping for inspection

I'll go ahead with parsing the body in the middleware for now. I think this check should be updated though to conform to the interface (assuming it's not) or be removed entirely so it's more clear that the body should be parsed in the middleware prior.

@oojacoboo oojacoboo deleted the patch-1 branch July 7, 2022 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants