'PHP graphql $response->getBody()->getContents() get "debugMessage":"Expected a value of type error
I am using PHP guzzlephp to query the data. Got the "debugMessage":"Expected a value of type error. The error comes from $content = $response->getBody()->getContents(); looks like it's not able to parse the response body. The wired thing is if the response is "laneStrategy": "COST": it will be parsed well, but if change to others, it throw the error. I have a enum defined like this:
class LaneStrategy {
const COST = 1;
const SPEED = 2;
const ORCHESTRATION = 3;
const STANDARD = 4;
}
correct response:
{
"lane": {
"laneID": 20234,
"laneStrategy": "COST",
"stops": [
{
"sequenceNumber": 0,
"node": {
"nodeID": 200
}
},
{
"sequenceNumber": 1,
"node": {
"nodeID": 100
}
}
]
}
}
When the response contains other type for laneStrategy except "COST" it will throw
error message: "errors":[{"debugMessage":"Expected a value of type \u0022LaneStrategy\u0022 but 2 received In the error message the 2 is exactly the number defined in enum, but I just don't get it why it throw the error using other types? Can anybody know what possible wrong? Thank you
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
