*/ private $_fragments; function __construct(Schema $schema, Document $ast, TypeInfo $typeInfo) { $this->_schema = $schema; $this->_ast = $ast; $this->_typeInfo = $typeInfo; } /** * @return Schema */ function getSchema() { return $this->_schema; } /** * @return Document */ function getDocument() { return $this->_ast; } /** * @param $name * @return FragmentDefinition|null */ function getFragment($name) { $fragments = $this->_fragments; if (!$fragments) { $this->_fragments = $fragments = array_reduce($this->getDocument()->definitions, function($frags, $statement) { if ($statement->kind === Node::FRAGMENT_DEFINITION) { $frags[$statement->name->value] = $statement; } return $frags; }, []); } return isset($fragments[$name]) ? $fragments[$name] : null; } /** * Returns OutputType * * @return Type */ function getType() { return $this->_typeInfo->getType(); } /** * @return CompositeType */ function getParentType() { return $this->_typeInfo->getParentType(); } /** * @return InputType */ function getInputType() { return $this->_typeInfo->getInputType(); } /** * @return FieldDefinition */ function getFieldDef() { return $this->_typeInfo->getFieldDef(); } }