originalInput = $params; $params += [ 'query' => null, 'queryid' => null, 'documentid' => null, // alias to queryid 'id' => null, // alias to queryid 'operation' => null, 'variables' => null ]; if ($params['variables'] === "") { $params['variables'] = null; } if (is_string($params['variables'])) { $tmp = json_decode($params['variables'], true); if (!json_last_error()) { $params['variables'] = $tmp; } } $instance->query = $params['query']; $instance->queryId = $params['queryid'] ?: $params['documentid'] ?: $params['id']; $instance->operation = $params['operation']; $instance->variables = $params['variables']; $instance->readOnly = (bool) $readonly; return $instance; } /** * @api * @param string $key * @return mixed */ public function getOriginalInput($key) { return isset($this->originalInput[$key]) ? $this->originalInput[$key] : null; } /** * Indicates that operation is executed in read-only context * (e.g. via HTTP GET request) * * @api * @return bool */ public function isReadOnly() { return $this->readOnly; } }