Youshido\GraphQL\Execution\Request::getFragment PHP Method

getFragment() public method

public getFragment ( $name ) : null | Fragment
$name
return null | Youshido\GraphQL\Parser\Ast\Fragment
    public function getFragment($name)
    {
        foreach ($this->fragments as $fragment) {
            if ($fragment->getName() == $name) {
                return $fragment;
            }
        }
        return null;
    }

Usage Example

Beispiel #1
0
 private function assertFragmentReferencesValid(Request $request)
 {
     foreach ($request->getFragmentReferences() as $fragmentReference) {
         if (!$request->getFragment($fragmentReference->getName())) {
             throw new InvalidRequestException(sprintf('Fragment "%s" not defined in query', $fragmentReference->getName()), $fragmentReference->getLocation());
         }
     }
 }
All Usage Examples Of Youshido\GraphQL\Execution\Request::getFragment