public function create(string $className, string $typeName): Type
    {
        $type = clone $this->types->getInput($className);
        $fieldsGetter = $type->config['fields'];

        $optionalFieldsGetter = function () use ($fieldsGetter): array {
            $optionalFields = [];
            foreach ($fieldsGetter() as $field) {
                if ($field['type'] instanceof NonNull) {
                    $field['type'] = $field['type']->getWrappedType();
                }

                unset($field['defaultValue']);

                $optionalFields[] = $field;
            }

            return $optionalFields;
        };
        $type->config['fields'] = $optionalFieldsGetter;
        $type->name = $typeName;

        return $type;
    }
public function create(string $className, string $typeName): Type
    {
        $type = clone $this->types->getInput($className);
        $fieldsGetter = $type->config['fields'];

        $optionalFieldsGetter = function () use ($fieldsGetter): array {
            $optionalFields = [];
            foreach ($fieldsGetter() as $field) {
                if ($field['type'] instanceof NonNull) {
                    $field['type'] = $field['type']->getWrappedType();
                }

                unset($field['defaultValue']);

                $optionalFields[] = $field;
            }

            return $optionalFields;
        };
        $type->config['fields'] = $optionalFieldsGetter;
        $type->name = $typeName;

        return $type;
    }
public function create ( string $ className , string $ typeName ) : Type { $ type = clone $ this -> types -> getInput ( $ className ) ; $ fieldsGetter = $ type -> config [ 'fields' ] ; $ optionalFieldsGetter = function ( ) use ( $ fieldsGetter ) : array { $ optionalFields = [ ] ; foreach ( $ fieldsGetter ( ) as $ field ) { if ( $ field [ 'type' ] instanceof NonNull ) { $ field [ 'type' ] = $ field [ 'type' ] -> getWrappedType ( ) ; } unset ( $ field [ 'defaultValue' ] ) ; $ optionalFields [ ] = $ field ; } return $ optionalFields ; } ; $ type -> config [ 'fields' ] = $ optionalFieldsGetter ; $ type -> name = $ typeName ; return $ type ; }
Create an InputObjectType from a Doctrine entity,
but will all fields as optional and without default values.

@param string $className class name of Doctrine entity
@param string $typeName GraphQL type name

@return InputObjectType
Create an InputObjectType from a Doctrine entity but will all fields as optional and without default values .