]> Dogcows Code - chaz/graphql-client/commitdiff
otions.transport not set to expanded var form
authorjwright <jwright@ecstuning.com>
Tue, 29 Mar 2022 21:15:59 +0000 (17:15 -0400)
committerjwright <jwright@ecstuning.com>
Tue, 29 Mar 2022 21:15:59 +0000 (17:15 -0400)
lib/GraphQL/Client/CLI.pm
t/cli.t

index c23e07fe4af9aeb5115218a0daf07ee051a726f1..8ddc78f4f4333a63246eb658706d3a8c9b99b3fe 100644 (file)
@@ -138,6 +138,7 @@ sub _get_options {
 
     my $transport = eval { _expand_vars($options{transport}) };
     die "Two or more --transport keys are incompatible.\n" if $@;
+    $options{transport} = $transport if ref $transport eq 'HASH' && %$transport;
 
     if (ref $options{variables}) {
         $options{variables} = eval { _expand_vars($options{variables}) };
diff --git a/t/cli.t b/t/cli.t
index a32af83b333f6189b694c70185f0d36b0e2a0cc6..142f2e5ad37979fcb045da8bb728c4d6adc48c8f 100755 (executable)
--- a/t/cli.t
+++ b/t/cli.t
@@ -44,6 +44,29 @@ subtest 'get_options' => sub {
     }
 };
 
+subtest 'get_options_transport' => sub {
+    my $expected = {
+        format          => 'json:pretty',
+        filter          => undef,
+        help            => undef,
+        manual          => undef,
+        operation_name  => undef,
+        outfile         => undef,
+        query           => 'bar',
+        transport       => { headers => {'X-Test' => 'value', 'X-Test-2' => 'val2' } },
+        unpack          => 0,
+        url             => 'foo',
+        variables       => undef,
+        version         => undef,
+    };
+
+    my $r = GraphQL::Client::CLI->_get_options(qw{--url foo --query bar --transport headers.X-Test=value --transport headers.X-Test-2=val2});
+    is_deeply($r, $expected, '--url, --query set option and correctly expanded transport options') or diag explain $r;
+};
+
+
+
+
 subtest 'expand_vars' => sub {
     my $r = GraphQL::Client::CLI::_expand_vars({
         'foo.bar'       => 'baz',
This page took 0.031926 seconds and 4 git commands to generate.