GraphQL\Error\Error::toSerializableArray PHP Méthode

toSerializableArray() public méthode

Returns array representation of error suitable for serialization
public toSerializableArray ( ) : array
Résultat array
    public function toSerializableArray()
    {
        $arr = ['message' => $this->getMessage()];
        $locations = Utils::map($this->getLocations(), function (SourceLocation $loc) {
            return $loc->toSerializableArray();
        });
        if (!empty($locations)) {
            $arr['locations'] = $locations;
        }
        if (!empty($this->path)) {
            $arr['path'] = $this->path;
        }
        return $arr;
    }

Usage Example

Exemple #1
0
 /**
  * @it serializes to include path
  */
 public function testSerializesToIncludePath()
 {
     $e = new Error('msg', null, null, null, ['path', 3, 'to', 'field']);
     $this->assertEquals(['path', 3, 'to', 'field'], $e->path);
     $this->assertEquals(['message' => 'msg', 'path' => ['path', 3, 'to', 'field']], $e->toSerializableArray());
 }
All Usage Examples Of GraphQL\Error\Error::toSerializableArray