check if query string exists in drupal 8 code example
Example: drupal 8 get url query parameters
// URL query parameter.
\Drupal::request()->query->get('keys');
\Drupal::request()->query->all()
// URL query parameter.
\Drupal::request()->query->get('keys');
\Drupal::request()->query->all()