GraphQL\Type\SchemaValidator::noOutputTypesAsInputArgsRule PHP Méthode

noOutputTypesAsInputArgsRule() public static méthode

public static noOutputTypesAsInputArgsRule ( )
    public static function noOutputTypesAsInputArgsRule()
    {
        return function ($context) {
            /** @var Schema $schema */
            $schema = $context['schema'];
            $typeMap = $schema->getTypeMap();
            $errors = [];
            foreach ($typeMap as $typeName => $type) {
                if ($type instanceof InputObjectType) {
                    $fields = $type->getFields();
                    foreach ($fields as $fieldName => $field) {
                        if (!Type::isInputType($field->getType())) {
                            $errors[] = new Error("Input field {$type->name}.{$field->name} has type " . "{$field->getType()}, which is not an input type!");
                        }
                    }
                }
            }
            return !empty($errors) ? $errors : null;
        };
    }

Usage Example

 private function assertAcceptingFieldArgOfType($fieldArgType)
 {
     $schema = $this->schemaWithFieldArgOfType($fieldArgType);
     $validationResult = SchemaValidator::validate($schema, [SchemaValidator::noOutputTypesAsInputArgsRule()]);
     $this->assertSame(true, $validationResult->isValid);
 }
All Usage Examples Of GraphQL\Type\SchemaValidator::noOutputTypesAsInputArgsRule