@@ -49,18 +49,13 @@ public function resolve($definition)
49
49
throw new \InvalidArgumentException ('$definition must be an instance of ' . Definition::class);
50
50
}
51
51
52
- $ headers = ['Content-type ' => 'application/json ' ];
53
-
54
52
$ url = $ this ->getIterator ()->get ('url ' , $ definition );
55
53
$ query = $ this ->getIterator ()->get ('query ' , $ definition );
56
54
$ method = $ definition ->has ('method ' ) ? $ this ->getIterator ()->get ('method ' , $ definition ) : 'POST ' ;
57
55
$ variables = $ definition ->has ('variables ' ) ? $ this ->getIterator ()->get ('variables ' , $ definition ) : [];
58
56
$ ignoreSSLErrors = $ definition ->has ('ignoreSSLErrors ' )
59
57
? $ this ->getIterator ()->get ('ignoreSSLErrors ' , $ definition )
60
58
: false ;
61
- $ headers = $ definition ->has ('headers ' )
62
- ? array_merge ($ headers , $ this ->getIterator ()->get ('headers ' , $ definition ))
63
- : $ headers ;
64
59
$ requestParams = [
65
60
'query ' => $ query ,
66
61
'variables ' => $ variables ,
@@ -73,14 +68,23 @@ public function resolve($definition)
73
68
CURLOPT_SSL_VERIFYPEER => !$ ignoreSSLErrors ,
74
69
],
75
70
]);
71
+
76
72
$ client ->setMethod ($ method );
77
- $ client -> setHeaders ( $ headers );
73
+
78
74
if ($ method === 'POST ' ) {
75
+ $ headers = $ definition ->has ('headers ' )
76
+ ? array_merge (['Content-type ' => 'application/json ' ], $ this ->getIterator ()->get ('headers ' , $ definition ))
77
+ : ['Content-type ' => 'application/json ' ];
78
+
79
79
$ client ->setRawBody (json_encode ($ requestParams ));
80
80
} elseif ($ method === 'GET ' ) {
81
+ $ headers = $ definition ->has ('headers ' ) ? $ this ->getIterator ()->get ('headers ' , $ definition ) : [];
82
+
81
83
$ client ->setParameterGet ($ requestParams );
82
84
}
83
85
86
+ $ client ->setHeaders ($ headers );
87
+
84
88
$ response = $ client ->send ();
85
89
86
90
return json_decode ($ response ->getBody (), true );
0 commit comments