]> Dogcows Code - chaz/graphql-client/commitdiff
Version 0.601
authorCharles McGarvey <chazmcgarvey@brokenzipper.com>
Mon, 16 Mar 2020 02:39:58 +0000 (20:39 -0600)
committerCharles McGarvey <chazmcgarvey@brokenzipper.com>
Mon, 16 Mar 2020 02:39:58 +0000 (20:39 -0600)
Changes
META.json
META.yml
Makefile.PL
README
bin/graphql
lib/GraphQL/Client.pm
lib/GraphQL/Client/http.pm
lib/GraphQL/Client/https.pm
t/client.t

diff --git a/Changes b/Changes
index c54d2b529f9251c9bde2ebbb43ba28372b6d6511..81a7db9b01f1082b67e96eec121f71448667e591 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,9 @@
 Revision history for GraphQL-Client.
 
+0.601     2020-03-15 20:38:38-06:00 MST7MDT
+  * Rename "class" attribute to "transport_class".
+  * Minor pod fixups.
+
 0.600     2020-03-15 18:08:57-06:00 MST7MDT
-  * Initial public release
+  * Initial public release.
 
index 737e3edad2d913f264aca63cabed81109abeaa7e..7139b3837deac7298adb7477dc9275763a68c173 100644 (file)
--- a/META.json
+++ b/META.json
    "provides" : {
       "GraphQL::Client" : {
          "file" : "lib/GraphQL/Client.pm",
-         "version" : "0.600"
+         "version" : "0.601"
       },
       "GraphQL::Client::Error" : {
          "file" : "lib/GraphQL/Client.pm",
-         "version" : "0.600"
+         "version" : "0.601"
       },
       "GraphQL::Client::http" : {
          "file" : "lib/GraphQL/Client/http.pm",
-         "version" : "0.600"
+         "version" : "0.601"
       },
       "GraphQL::Client::https" : {
          "file" : "lib/GraphQL/Client/https.pm",
-         "version" : "0.600"
+         "version" : "0.601"
       }
    },
    "release_status" : "stable",
          "web" : "https://github.com/chazmcgarvey/graphql-client"
       }
    },
-   "version" : "0.600",
+   "version" : "0.601",
    "x_authority" : "cpan:CCM",
    "x_generated_by_perl" : "v5.28.0",
    "x_serialization_backend" : "Cpanel::JSON::XS version 4.15",
index ef5ab68f298b6575c720bd3d554427f45373347b..727e00dd61bd016a3a867c4ed4046b9f9e2bc460 100644 (file)
--- a/META.yml
+++ b/META.yml
@@ -33,16 +33,16 @@ no_index:
 provides:
   GraphQL::Client:
     file: lib/GraphQL/Client.pm
-    version: '0.600'
+    version: '0.601'
   GraphQL::Client::Error:
     file: lib/GraphQL/Client.pm
-    version: '0.600'
+    version: '0.601'
   GraphQL::Client::http:
     file: lib/GraphQL/Client/http.pm
-    version: '0.600'
+    version: '0.601'
   GraphQL::Client::https:
     file: lib/GraphQL/Client/https.pm
-    version: '0.600'
+    version: '0.601'
 recommends:
   HTTP::Tiny: '0'
   Pod::Usage: '0'
@@ -64,7 +64,7 @@ resources:
   bugtracker: https://github.com/chazmcgarvey/graphql-client/issues
   homepage: https://github.com/chazmcgarvey/graphql-client
   repository: https://github.com/chazmcgarvey/graphql-client.git
-version: '0.600'
+version: '0.601'
 x_authority: cpan:CCM
 x_generated_by_perl: v5.28.0
 x_serialization_backend: 'YAML::Tiny version 1.73'
index 491a896e2f71f7704e2d6abe07e6f7c82df2669b..7d75ca6fdc173d25cd287a2fe7ea81f3b8f68476 100644 (file)
@@ -46,7 +46,7 @@ my %WriteMakefileArgs = (
     "Test::More" => 0,
     "lib" => 0
   },
-  "VERSION" => "0.600",
+  "VERSION" => "0.601",
   "test" => {
     "TESTS" => "t/*.t"
   }
diff --git a/README b/README
index ba5570e84cc18717ea819bac7001b17bc437cb34..ae64d68d1a89769935251ca5f56aa35fbc23feca 100644 (file)
--- a/README
+++ b/README
@@ -4,7 +4,7 @@ NAME
 
 VERSION
 
-    version 0.600
+    version 0.601
 
 SYNOPSIS
 
@@ -52,7 +52,8 @@ DESCRIPTION
     GraphQL::Client provides a simple way to execute GraphQL
     <https://graphql.org/> queries and mutations on a server.
 
-    This module is the programmatic interface. There is also a graphql.
+    This module is the programmatic interface. There is also a "CLI
+    program".
 
     GraphQL servers are usually served over HTTP. The provided transport,
     GraphQL::Client::http, lets you plug in your own user agent, so this
@@ -65,27 +66,28 @@ ATTRIBUTES
 
     The URL of a GraphQL endpoint, e.g. "http://myapiserver/graphql".
 
- class
+ unpack
 
-    The package name of a transport.
+    Whether or not to "unpack" the response, which enables a different
+    style for error-handling.
 
-    By default this is automatically determined from the protocol portion
-    of the "url".
+    Default is 0.
 
- transport
+    See "ERROR HANDLING".
 
-    The transport object.
+ transport_class
 
-    By default this is automatically constructed based on the "class".
+    The package name of a transport.
 
- unpack
+    This is optional if the correct transport can be correctly determined
+    from the "url".
 
-    Whether or not to "unpack" the response, which enables a different
-    style for error-handling.
+ transport
 
-    Default is 0.
+    The transport object.
 
-    See "ERROR HANDLING".
+    By default this is automatically constructed based on "transport_class"
+    or "url".
 
 METHODS
 
@@ -126,8 +128,8 @@ ERROR HANDLING
 
     There are two different styles for handling errors.
 
-    If "unpack" is 0 (off), every response -- whether success or failure --
-    is enveloped like this:
+    If "unpack" is 0 (off, the default), every response -- whether success
+    or failure -- is enveloped like this:
 
         {
             data   => {...},
@@ -156,6 +158,7 @@ ERROR HANDLING
 
         my $data = eval { $graphql->execute(...) };
         if (my $error = $@) {
+            my $resp = $error->{response};
             # handle errors
         }
         else {
index 31c48aeb1109a58205ce70161b41f8ed00dd222a..6825edc71261b3c44d64b343f0b8fab5a916c9c9 100755 (executable)
@@ -11,7 +11,7 @@ use Getopt::Long;
 use GraphQL::Client;
 use JSON::MaybeXS;
 
-our $VERSION = '0.600'; # VERSION
+our $VERSION = '0.601'; # VERSION
 
 my $version;
 my $help;
@@ -228,7 +228,7 @@ graphql - Command-line GraphQL client
 
 =head1 VERSION
 
-version 0.600
+version 0.601
 
 =head1 SYNOPSIS
 
index 2f844fe5b5c983ca1731675a2af458302eeb6757..8b93e4b0f0def250a6a8ccfd6638240b723a8969 100644 (file)
@@ -8,7 +8,7 @@ use Module::Load qw(load);
 use Scalar::Util qw(reftype);
 use namespace::clean;
 
-our $VERSION = '0.600'; # VERSION
+our $VERSION = '0.601'; # VERSION
 
 sub _croak { require Carp; goto &Carp::croak }
 sub _throw { GraphQL::Client::Error->throw(@_) }
@@ -83,15 +83,15 @@ sub url {
     $self->{url};
 }
 
-sub class {
+sub transport_class {
     my $self = shift;
-    $self->{class};
+    $self->{transport_class};
 }
 
 sub transport {
     my $self = shift;
     $self->{transport} //= do {
-        my $class = $self->_transport_class;
+        my $class = $self->_autodetermine_transport_class;
         eval { load $class };
         if ((my $err = $@) || !$class->can('execute')) {
             $err ||= "Loaded $class, but it doesn't look like a proper transport.\n";
@@ -116,15 +116,16 @@ sub _url_protocol {
     return $protocol;
 }
 
-sub _transport_class {
+sub _autodetermine_transport_class {
     my $self = shift;
 
-    return _expand_class($self->{class}) if $self->{class};
+    my $class = $self->transport_class;
+    return _expand_class($class) if $class;
 
     my $protocol = $self->_url_protocol;
     _croak 'Failed to determine transport from URL' if !$protocol;
 
-    my $class = lc($protocol);
+    $class = lc($protocol);
     $class =~ s/[^a-z]/_/g;
 
     return _expand_class($class);
@@ -170,7 +171,7 @@ GraphQL::Client - A GraphQL client
 
 =head1 VERSION
 
-version 0.600
+version 0.601
 
 =head1 SYNOPSIS
 
@@ -218,7 +219,7 @@ version 0.600
 C<GraphQL::Client> provides a simple way to execute L<GraphQL|https://graphql.org/> queries and
 mutations on a server.
 
-This module is the programmatic interface. There is also a L<graphql|"CLI program">.
+This module is the programmatic interface. There is also a L<"CLI program"|graphql>.
 
 GraphQL servers are usually served over HTTP. The provided transport, L<GraphQL::Client::http>, lets
 you plug in your own user agent, so this client works naturally with L<HTTP::Tiny>,
@@ -230,25 +231,25 @@ L<Mojo::UserAgent>, and more. You can also use L<HTTP::AnyUA> middleware.
 
 The URL of a GraphQL endpoint, e.g. C<"http://myapiserver/graphql">.
 
-=head2 class
+=head2 unpack
 
-The package name of a transport.
+Whether or not to "unpack" the response, which enables a different style for error-handling.
 
-By default this is automatically determined from the protocol portion of the L</url>.
+Default is 0.
 
-=head2 transport
+See L</ERROR HANDLING>.
 
-The transport object.
+=head2 transport_class
 
-By default this is automatically constructed based on the L</class>.
+The package name of a transport.
 
-=head2 unpack
+This is optional if the correct transport can be correctly determined from the L</url>.
 
-Whether or not to "unpack" the response, which enables a different style for error-handling.
+=head2 transport
 
-Default is 0.
+The transport object.
 
-See L</ERROR HANDLING>.
+By default this is automatically constructed based on L</transport_class> or L</url>.
 
 =head1 METHODS
 
@@ -288,7 +289,8 @@ Note: Setting the L</unpack> attribute affects the response shape.
 
 There are two different styles for handling errors.
 
-If L</unpack> is 0 (off), every response -- whether success or failure -- is enveloped like this:
+If L</unpack> is 0 (off, the default), every response -- whether success or failure -- is enveloped
+like this:
 
     {
         data   => {...},
@@ -314,6 +316,7 @@ otherwise it will throw an exception. So your code would instead look like this:
 
     my $data = eval { $graphql->execute(...) };
     if (my $error = $@) {
+        my $resp = $error->{response};
         # handle errors
     }
     else {
index 7adf4a4671063227206946297afcf8aec10b9ce8..a53228af1566b08312e0541fc4fa0a7d986d7daa 100644 (file)
@@ -9,7 +9,7 @@ use HTTP::AnyUA::Util qw(www_form_urlencode);
 use HTTP::AnyUA;
 use namespace::clean;
 
-our $VERSION = '0.600'; # VERSION
+our $VERSION = '0.601'; # VERSION
 
 sub _croak { require Carp; goto &Carp::croak }
 
@@ -169,7 +169,7 @@ GraphQL::Client::http - GraphQL over HTTP
 
 =head1 VERSION
 
-version 0.600
+version 0.601
 
 =head1 SYNOPSIS
 
@@ -188,7 +188,7 @@ version 0.600
             authorization => 'Bearer s3cr3t',
         },
     };
-    my $response = $client->execute($request, $options);
+    my $response = $transport->execute($request, $options);
 
 =head1 DESCRIPTION
 
index 64676644719945bc03df4c10ca2baccbac7e905b..f73b48f4f282b7e5dcd0a1e566482177a019c24f 100644 (file)
@@ -6,7 +6,7 @@ use strict;
 
 use parent 'GraphQL::Client::http';
 
-our $VERSION = '0.600'; # VERSION
+our $VERSION = '0.601'; # VERSION
 
 sub new {
     my $class = shift;
@@ -27,7 +27,7 @@ GraphQL::Client::https - GraphQL over HTTPS
 
 =head1 VERSION
 
-version 0.600
+version 0.601
 
 =head1 DESCRIPTION
 
index 4775b70036f8c44cc12b10285b9f3bb6a15184b3..1dd0cd425ab19c5f519bee7ab5a63e7a791d173d 100755 (executable)
@@ -14,14 +14,14 @@ use GraphQL::Client;
 use MockTransport;
 
 subtest 'transport' => sub {
-    my $client = GraphQL::Client->new(class => 'http');
-    isa_ok($client->transport, 'GraphQL::Client::http', 'decide transport from class');
+    my $client = GraphQL::Client->new(transport_class => 'http');
+    isa_ok($client->transport, 'GraphQL::Client::http', 'decide transport from transport_class');
 
     $client = GraphQL::Client->new(url => 'https://localhost:4000/graphql');
     isa_ok($client->transport, 'GraphQL::Client::http', 'decide transport from url');
 
-    $client = GraphQL::Client->new(class => 'not a real class');
-    is($client->class, 'not a real class', 'class constructor works');
+    $client = GraphQL::Client->new(transport_class => 'not a real class');
+    is($client->transport_class, 'not a real class', 'transport_class constructor works');
     throws_ok { $client->transport } qr/^Failed to load transport/, 'throws if invalid transport';
 };
 
This page took 0.032577 seconds and 4 git commands to generate.