diff --git a/lib/global_id/uri/gid.rb b/lib/global_id/uri/gid.rb
index <HASH>..<HASH> 100644
--- a/lib/global_id/uri/gid.rb
+++ b/lib/global_id/uri/gid.rb
@@ -89,7 +89,7 @@ module URI
 
     def to_s
       # Implement #to_s to avoid no implicit conversion of nil into string when path is nil
-      "gid://#{app}#{path_query}"
+      "gid://#{app}#{path}#{'?' + query if query}"
     end
 
     protected
Avoid using internal path_query method.