How to load a entity or node in form builder class? I want to load default values in my form. I am fetching the node of the table row from form list and passing it into route.

my_form_eform:
 path: '/edit/{bar}'
 options:
 parameters:
  bar:
  type: entity:node
 defaults:
  _form: '\Drupal\my_form\Form\EditForm'
  _title: 'Edit Item'
 requirements:
  _permission: 'access content'


and code for editform.php is 

namespace Drupal\my_form\Form;

use Drupal\Core\Session\AccountInterface;
use Symfony\Component\HttpFoundation\Request;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Form\NodeInterface;

class EditForm extends FormBase{


// public function content(AccountInterface $index, Request $request) {

public function getFormId() {
return 'edit_form';
}

public function buildForm(array $form, FormStateInterface $form_state , NodeInterface $bar = NULL){

 // $id = $bar;
//  $result = db_select('my_form','t')  
// -&gt;fields('t',array('id','title','author','stream','description','price'))
// -&gt;condition('id',$id) 
// -&gt;execute()-&gt;fetchAssoc();

// $dtitle = $result['title'];
// $dauthor = $result['author'];
// $ddesc = $result['description'];
// $dstream = $result['stream'];
// $dprice = $result['price'];

$form = array();

$form['title'] = [
  '#type' =&gt; 'textfield',
  '#title' =&gt; t('Title of your book.'),
   '#default_value'=&gt; $dtitle
];
$form['author'] = [
  '#type' =&gt; 'textfield',
  '#title' =&gt; $this-&gt;t('Author.'),
   '#default_value'=&gt; $dauthor
  ];
$form['stream'] = [
  '#type' =&gt; 'select',
  '#title' =&gt; t('Stream'),
  '#options' =&gt; array(
  'ECE' =&gt; t('ECE'),
  'CSE' =&gt; t('CSE'),
  'ME'=&gt; t('ME'),
),
   '#default_value'=&gt; $dstream
  ];
  $form['desc'] = [
  '#type' =&gt; 'textfield',
  '#title' =&gt; t('Description'),
   '#default_value'=&gt; $ddesc
  ];
  $form['Price'] = [
  '#type' =&gt; 'textfield',
  '#title' =&gt; t('Price'),
   '#default_value'=&gt; $dprice,
  ];
$form['ADD'] = [
  '#type' =&gt; 'submit',
  '#value' =&gt; $this-&gt;t('Update'),
];
return $form;


}

I read about parameter upcasting, but its not required for node instance.

If I am passing the id in function itself through account interface it's giving the error


  must be compatible with formbuilder class


Now I am using NodeInterface argument but its also giving the error


  Argument 3 passed to Drupal\my_form\Form\EditForm::buildForm() must be an instance of Drupal\Core\Form\NodeInterface


Please help. How can I load my id so that default values for form fields can be fetched from db?
You need to make it an optional argument. Annoying but unavoidable workaround with the current design.

And to have it already upcasted to a node, you need to name your variable {node}.