Ejemplo n.º 1
0
 /**
  * @return \Fubhy\GraphQL\Type\Directives\DirectiveInterface[]
  */
 public function getDirectives()
 {
     if (!isset($this->directives)) {
         $include = Directive::includeDirective();
         $skip = Directive::skipDirective();
         $this->directives = [$include->getName() => $include, $skip->getName() => $skip];
     }
     return $this->directives;
 }
Ejemplo n.º 2
0
 /**
  * Determines if a field should be included based on @if and @unless directives.
  */
 protected static function shouldIncludeNode(ExecutionContext $exeContext, $directives)
 {
     $skip = Directive::skipDirective();
     $include = Directive::includeDirective();
     foreach ($directives as $directive) {
         if ($directive->get('name')->get('value') === $skip->getName()) {
             $values = Values::getArgumentValues($skip->getArguments(), $directive->get('arguments'), $exeContext->variables);
             return empty($values['if']);
         }
         if ($directive->get('name')->get('value') === $include->getName()) {
             $values = Values::getArgumentValues($skip->getArguments(), $directive->get('arguments'), $exeContext->variables);
             return !empty($values['if']);
         }
     }
     return TRUE;
 }