File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -493,16 +493,21 @@ public function parsePsrRequest(ServerRequestInterface $request)
493493                    );
494494                }
495495
496+                 // Try parsing ourselves if PSR-7 implementation doesn't parse JSON automatically 
497+                 if  (is_array ($ bodyParams ) && empty ($ bodyParams )) {
498+                     $ bodyParams  = json_decode ($ request ->getBody (), true );
499+ 
500+                     if  (json_last_error ()) {
501+                         throw  new  RequestError ("Could not parse JSON:  "  . json_last_error_msg ());
502+                     }
503+                 }
504+ 
496505                if  (!is_array ($ bodyParams )) {
497506                    throw  new  RequestError (
498507                        "GraphQL Server expects JSON object or array, but got  "  .
499508                        Utils::printSafeJson ($ bodyParams )
500509                    );
501510                }
502- 
503-                 if  (empty ($ bodyParams )) {
504-                     $ bodyParams  = json_decode ($ request ->getBody (), true );
505-                 }
506511            } else  {
507512                $ bodyParams  = $ request ->getParsedBody ();
508513
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments