| 1 | package DBIx::Class::Schema::GraphQL; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 8 | ▶ | use version; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 8 | our $VERSION = qv('v0.0.3'); | |||||||||||||||||||||||||||
| 8 | 8 | our $AUTHORITY = 'cpan:MANWAR'; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | =head1 NAME | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | DBIx::Class::Schema::GraphQL - Auto-generate a GraphQL schema from a DBIx::Class schema | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | =head1 VERSION | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | Version v0.0.3 | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | =cut | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 8 | ▶ | use MIME::Base64 qw(encode_base64 decode_base64); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 8 | ▶ | use GraphQL::Schema; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 8 | ▶ | use GraphQL::Type::Object; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 8 | ▶ | use GraphQL::Type::InputObject; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 8 | ▶ | use GraphQL::Type::List; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | 8 | ▶ | use GraphQL::Type::NonNull; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 27 | 8 | ▶ | use GraphQL::Type::Enum; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | 8 | ▶ | use GraphQL::Type::Scalar qw($Int $String $Float $Boolean); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | use DBIx::Class::Schema::GraphQL; | ||||||||||||||||||||||||||||
| 33 | use GraphQL::Execution qw(execute); | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | my $db = My::Schema->connect(...); | ||||||||||||||||||||||||||||
| 36 | my $result = DBIx::Class::Schema::GraphQL->to_graphql($db); | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | # Simple plural query - always include at least one scalar field | ||||||||||||||||||||||||||||
| 39 | # alongside nodes (e.g. total) - see KNOWN BEHAVIOUR below. | ||||||||||||||||||||||||||||
| 40 | execute($result->{schema}, | ||||||||||||||||||||||||||||
| 41 | '{ allBooks { total nodes { title } } }', | ||||||||||||||||||||||||||||
| 42 | undef, $result->{context}); | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | # Filtered + paginated + ordered | ||||||||||||||||||||||||||||
| 45 | execute($result->{schema}, ' | ||||||||||||||||||||||||||||
| 46 | query { | ||||||||||||||||||||||||||||
| 47 | allBooks( | ||||||||||||||||||||||||||||
| 48 | filter: { title_like: "%Perl%" } | ||||||||||||||||||||||||||||
| 49 | orderBy: { field: "title", direction: ASC } | ||||||||||||||||||||||||||||
| 50 | page: { skip: 0, take: 5 } | ||||||||||||||||||||||||||||
| 51 | ) { | ||||||||||||||||||||||||||||
| 52 | total | ||||||||||||||||||||||||||||
| 53 | hasNextPage | ||||||||||||||||||||||||||||
| 54 | nodes { id title } | ||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | }', undef, $result->{context}); | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | # Cursor pagination | ||||||||||||||||||||||||||||
| 59 | execute($result->{schema}, ' | ||||||||||||||||||||||||||||
| 60 | query($after: String) { | ||||||||||||||||||||||||||||
| 61 | allBooks(cursor: { after: $after, first: 5 }) { | ||||||||||||||||||||||||||||
| 62 | total | ||||||||||||||||||||||||||||
| 63 | nextCursor | ||||||||||||||||||||||||||||
| 64 | hasNextPage | ||||||||||||||||||||||||||||
| 65 | nodes { id title } | ||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | }', undef, $result->{context}, { after => $cursor }); | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | # Mutation: Full update (all non-key columns) | ||||||||||||||||||||||||||||
| 70 | execute($result->{schema}, | ||||||||||||||||||||||||||||
| 71 | 'mutation { createBook(title: "Dune", author_id: 4) { id title } }', | ||||||||||||||||||||||||||||
| 72 | undef, $result->{context}); | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | # Mutation: Sparse update (only supplied columns are changed) | ||||||||||||||||||||||||||||
| 75 | execute($result->{schema}, | ||||||||||||||||||||||||||||
| 76 | 'mutation { patchBook(id: 1, title: "Dune Messiah") { id title } }', | ||||||||||||||||||||||||||||
| 77 | undef, $result->{context}); | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | Introspects every source registered with the supplied L<DBIx::Class::Schema> | ||||||||||||||||||||||||||||
| 82 | and builds a complete, executable L<GraphQL::Schema> with: | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | =over 4 | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =item * One scalar field per column, typed as C<Int>, C<Float>, C<Boolean>, | ||||||||||||||||||||||||||||
| 87 | or C<String> based on the column's declared C<data_type>. | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | =item * One relationship field per DBIC relationship (C<has_many> resolves to | ||||||||||||||||||||||||||||
| 90 | a List type; C<belongs_to> / C<might_have> resolve to a single object type). | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | =item * A root C<Query> type with singular lookup and plural | ||||||||||||||||||||||||||||
| 93 | C<allE<lt>SourceE<gt>s> queries supporting filtering, ordering, and both | ||||||||||||||||||||||||||||
| 94 | offset and cursor pagination. | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | =item * A root C<Mutation> type with C<createX>, C<updateX>, C<patchX>, and | ||||||||||||||||||||||||||||
| 97 | C<deleteX> entry points for every source. | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | =back | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | Composite primary keys are fully supported throughout. | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | =head1 METHODS | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | =head2 to_graphql | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | my $result = DBIx::Class::Schema::GraphQL->to_graphql($db); | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | Class method. Accepts a connected L<DBIx::Class::Schema> instance. | ||||||||||||||||||||||||||||
| 110 | Returns a hashref: | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | { | ||||||||||||||||||||||||||||
| 113 | schema => $graphql_schema, # GraphQL::Schema, pass to execute() | ||||||||||||||||||||||||||||
| 114 | context => $db, # the original schema, for convenience | ||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | =cut | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 0 | ▶ | sub to_graphql { | ||||||||||||||||||||||||||
|
Subroutine
to_graphql: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 120 | 0 | my ($class, $db) = @_; | |||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 0 | my $shared = _build_shared_types(); | |||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | # Phase 1: Shell types | ||||||||||||||||||||||||||||
| 125 | 0 | my %gql_types; | |||||||||||||||||||||||||||
| 126 | 0 | for my $moniker ($db->sources) { | |||||||||||||||||||||||||||
| 127 | $gql_types{$moniker} = GraphQL::Type::Object->new( | ||||||||||||||||||||||||||||
| 128 | name => $moniker, | ||||||||||||||||||||||||||||
| 129 | description => "Auto-generated GraphQL type for DBIx::Class source '$moniker'", | ||||||||||||||||||||||||||||
| 130 | 0 | ▶ | fields => sub { {} }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 131 | 0 | ); | |||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | # Phase 2: Real fields (safe because %gql_types is fully populated) | ||||||||||||||||||||||||||||
| 135 | 0 | for my $moniker ($db->sources) { | |||||||||||||||||||||||||||
| 136 | 0 | my $source_obj = $db->source($moniker); | |||||||||||||||||||||||||||
| 137 | 0 | my $this_moniker = $moniker; | |||||||||||||||||||||||||||
| 138 | 0 | my %types_snapshot = %gql_types; | |||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | 0 | ▶ | $gql_types{$moniker}->{fields} = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||
| 141 | 0 | my %fields; | |||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | 0 | for my $col ($source_obj->columns) { | |||||||||||||||||||||||||||
| 144 | 0 | $fields{$col} = { type => _scalar_for_column($source_obj, $col) }; | |||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | 0 | for my $rel ($source_obj->relationships) { | |||||||||||||||||||||||||||
| 148 | 0 | my $rel_info = $source_obj->relationship_info($rel); | |||||||||||||||||||||||||||
| 149 | 0 | my $target_moniker = $rel_info->{source}; | |||||||||||||||||||||||||||
| 150 | 0 | $target_moniker =~ s/^.*:://; | |||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 0 | ▶ | my $target_type = $types_snapshot{$target_moniker} or next; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | my $is_plural = ( | ||||||||||||||||||||||||||||
| 155 | $rel_info->{attrs}{accessor} | ||||||||||||||||||||||||||||
| 156 | 0 | ▶ | && $rel_info->{attrs}{accessor} eq 'multi' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$rel_info->{"attrs"}{"accessor"} and $rel_info->{"attrs"}{"accessor"} eq "multi"
MC/DC0%0/2
$rel_info->{"attrs"}{"accessor"} and $rel_info->{"attrs"}{"accessor"} eq "multi"
$rel_info->{"attrs"}{"accessor"}
$rel_info->{"attrs"}{"accessor"} eq "multi"
Truth table0%0/3
A and B
A= $rel_info->{"attrs"}{"accessor"}B= $rel_info->{"attrs"}{"accessor"} eq "multi"
| |||||||||||||||||||||||||||||
| 157 | ) ? 1 : 0; | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | 0 | my ($captured_rel, $captured_moniker, $captured_plural) | |||||||||||||||||||||||||||
| 160 | = ($rel, $this_moniker, $is_plural); | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | $fields{$rel} = { | ||||||||||||||||||||||||||||
| 163 | type => $is_plural | ||||||||||||||||||||||||||||
| 164 | ? GraphQL::Type::List->new(of => $target_type) | ||||||||||||||||||||||||||||
| 165 | : $target_type, | ||||||||||||||||||||||||||||
| 166 | 0 | ▶ | resolve => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 167 | 0 | my ($row, $args, $ctx) = @_; | |||||||||||||||||||||||||||
| 168 | 0 | ▶ | if (ref($row) eq 'HASH') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 169 | 0 | ▶ | $row = _pk_find($ctx, $captured_moniker, $row) or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | 0 | ▶ | if ($captured_plural) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 172 | return [ | ||||||||||||||||||||||||||||
| 173 | 0 | map { { $_->get_columns } } | |||||||||||||||||||||||||||
| 174 | $row->$captured_rel->all | ||||||||||||||||||||||||||||
| 175 | ]; | ||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||
| 177 | else { | ||||||||||||||||||||||||||||
| 178 | 0 | my $related = $row->$captured_rel; | |||||||||||||||||||||||||||
| 179 | 0 | ▶ | return $related ? { $related->get_columns } : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||
| 181 | }, | ||||||||||||||||||||||||||||
| 182 | 0 | ▶ | }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | 0 | return \%fields; | |||||||||||||||||||||||||||
| 186 | 0 | }; | |||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | # Phase 3: Root Query + Mutation types | ||||||||||||||||||||||||||||
| 190 | 0 | my (%query_fields, %mutation_fields); | |||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | 0 | for my $moniker ($db->sources) { | |||||||||||||||||||||||||||
| 193 | 0 | my $graphql_type = $gql_types{$moniker}; | |||||||||||||||||||||||||||
| 194 | 0 | my $source_obj = $db->source($moniker); | |||||||||||||||||||||||||||
| 195 | 0 | my $singular_args = _build_singular_args($source_obj); | |||||||||||||||||||||||||||
| 196 | 0 | my $filter_type = _build_filter_type($source_obj, $moniker); | |||||||||||||||||||||||||||
| 197 | 0 | my $connection_type = _build_connection_type($moniker, $graphql_type); | |||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | # Singular query | ||||||||||||||||||||||||||||
| 200 | $query_fields{ lcfirst($moniker) } = { | ||||||||||||||||||||||||||||
| 201 | type => $graphql_type, | ||||||||||||||||||||||||||||
| 202 | args => $singular_args, | ||||||||||||||||||||||||||||
| 203 | 0 | ▶ | resolve => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 204 | 0 | my ($root, $args, $ctx) = @_; | |||||||||||||||||||||||||||
| 205 | 0 | ▶ | return unless grep { defined $args->{$_} } keys %$singular_args; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 206 | 0 | my $row = $ctx->resultset($moniker)->find($args); | |||||||||||||||||||||||||||
| 207 | 0 | ▶ | return $row ? { $row->get_columns } : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 208 | }, | ||||||||||||||||||||||||||||
| 209 | 0 | }; | |||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | # Plural query with filter + pagination + ordering | ||||||||||||||||||||||||||||
| 212 | $query_fields{ 'all' . ucfirst($moniker) . 's' } = { | ||||||||||||||||||||||||||||
| 213 | type => $connection_type, | ||||||||||||||||||||||||||||
| 214 | description => "Fetch a filtered, paginated, ordered list of $moniker rows.", | ||||||||||||||||||||||||||||
| 215 | args => { | ||||||||||||||||||||||||||||
| 216 | filter => { type => $filter_type, | ||||||||||||||||||||||||||||
| 217 | description => "Column filters with exact, comparison, and logical operators." }, | ||||||||||||||||||||||||||||
| 218 | page => { type => $shared->{page_input}, | ||||||||||||||||||||||||||||
| 219 | description => "Offset pagination: skip N rows, take M rows." }, | ||||||||||||||||||||||||||||
| 220 | cursor => { type => $shared->{cursor_input}, | ||||||||||||||||||||||||||||
| 221 | description => "Cursor pagination: fetch first N rows after a cursor." }, | ||||||||||||||||||||||||||||
| 222 | orderBy => { type => $shared->{order_by_input}, | ||||||||||||||||||||||||||||
| 223 | description => "Order results by a column, ASC or DESC." }, | ||||||||||||||||||||||||||||
| 224 | }, | ||||||||||||||||||||||||||||
| 225 | 0 | ▶ | resolve => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 226 | 0 | my ($root, $args, $ctx) = @_; | |||||||||||||||||||||||||||
| 227 | 0 | ▶ | $args //= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args //= {}
MC/DC0%0/1
$args //= {}
$args
Truth table0%0/2
A
A= $args
| |||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | # Build the base filtered resultset | ||||||||||||||||||||||||||||
| 230 | 0 | my $rs = $ctx->resultset($moniker); | |||||||||||||||||||||||||||
| 231 | 0 | ▶ | if (my $filter = $args->{filter}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 232 | 0 | my $cond = _filter_to_dbic($filter, $ctx->source($moniker)); | |||||||||||||||||||||||||||
| 233 | 0 | ▶ | $rs = $rs->search($cond) if $cond && %$cond; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$cond and %$cond
MC/DC0%0/2
$cond and %$cond
$cond
%$cond
Truth table0%0/3
A and B
A= $condB= %$cond
| |||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | # Clone the rs for counting so pagination does not | ||||||||||||||||||||||||||||
| 237 | # affect the count query and vice-versa. | ||||||||||||||||||||||||||||
| 238 | 0 | my $count_rs = $rs->search_rs({}); | |||||||||||||||||||||||||||
| 239 | 0 | my $total = $count_rs->count; | |||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | 0 | my ($nodes, $next_cursor, $has_next) = | |||||||||||||||||||||||||||
| 242 | _apply_pagination($rs, $args, $ctx->source($moniker)); | ||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | return { | ||||||||||||||||||||||||||||
| 245 | 0 | nodes => $nodes, | |||||||||||||||||||||||||||
| 246 | total => $total, | ||||||||||||||||||||||||||||
| 247 | nextCursor => $next_cursor, | ||||||||||||||||||||||||||||
| 248 | hasNextPage => $has_next, | ||||||||||||||||||||||||||||
| 249 | }; | ||||||||||||||||||||||||||||
| 250 | }, | ||||||||||||||||||||||||||||
| 251 | 0 | }; | |||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | # Mutations | ||||||||||||||||||||||||||||
| 254 | 0 | %mutation_fields = ( | |||||||||||||||||||||||||||
| 255 | %mutation_fields, | ||||||||||||||||||||||||||||
| 256 | _build_mutation_fields($source_obj, $moniker, $graphql_type), | ||||||||||||||||||||||||||||
| 257 | ); | ||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | 0 | my $query_type = GraphQL::Type::Object->new( | |||||||||||||||||||||||||||
| 261 | name => 'Query', | ||||||||||||||||||||||||||||
| 262 | fields => \%query_fields, | ||||||||||||||||||||||||||||
| 263 | ); | ||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | 0 | my $mutation_type = GraphQL::Type::Object->new( | |||||||||||||||||||||||||||
| 266 | name => 'Mutation', | ||||||||||||||||||||||||||||
| 267 | description => 'Auto-generated create/update/patch/delete mutations', | ||||||||||||||||||||||||||||
| 268 | fields => \%mutation_fields, | ||||||||||||||||||||||||||||
| 269 | ); | ||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | 0 | my $schema = GraphQL::Schema->new( | |||||||||||||||||||||||||||
| 272 | query => $query_type, | ||||||||||||||||||||||||||||
| 273 | mutation => $mutation_type, | ||||||||||||||||||||||||||||
| 274 | ); | ||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | return { | ||||||||||||||||||||||||||||
| 277 | 0 | schema => $schema, | |||||||||||||||||||||||||||
| 278 | context => $db, | ||||||||||||||||||||||||||||
| 279 | }; | ||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | # | ||||||||||||||||||||||||||||
| 283 | # | ||||||||||||||||||||||||||||
| 284 | # INTERNAL METHODS | ||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | # _scalar_for_column($source, $col_name) | ||||||||||||||||||||||||||||
| 287 | # | ||||||||||||||||||||||||||||
| 288 | # Maps a DBIC column to a GraphQL scalar. Resolution order matters: | ||||||||||||||||||||||||||||
| 289 | # 1. Boolean: must come before Int because tinyint(1) is the MySQL idiom | ||||||||||||||||||||||||||||
| 290 | # 2. Float : decimal/numeric before the int catch-all | ||||||||||||||||||||||||||||
| 291 | # 3. Int : all integer family types | ||||||||||||||||||||||||||||
| 292 | # 4. String : safe fallback for anything unrecognised | ||||||||||||||||||||||||||||
| 293 | 40 | ▶ | sub _scalar_for_column { | ||||||||||||||||||||||||||
|
Subroutine
_scalar_for_column: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 294 | 40 | my ($source, $col) = @_; | |||||||||||||||||||||||||||
| 295 | 40 | my $info = $source->column_info($col); | |||||||||||||||||||||||||||
| 296 | 40 | ▶ | my $data_type = $info->{data_type} // ''; | ||||||||||||||||||||||||||
|
Condition100%2/2
$info->{"data_type"} // ""
MC/DC100%1/1
$info->{"data_type"} // ""
$info->{"data_type"}
Truth table100%2/2
A
A= $info->{"data_type"}
| |||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | 40 | ▶ | return $Boolean if $data_type =~ /(?:\b(?:bool(?:ean)?)|tinyint\(1\))(?=\s|\z)/i; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 299 | 33 | ▶ | return $Float if $data_type =~ /\b(?:float|double(?:\s+precision)?|real|money|decimal|numeric)\b/i; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 300 | 21 | ▶ | return $Int if $data_type =~ /\b(?:int(?:eger)?|bigint|smallint|tinyint|mediumint|serial)\b/i; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 301 | 10 | return $String; | |||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | 0 | ▶ | sub _col_is_required { | ||||||||||||||||||||||||||
|
Subroutine
_col_is_required: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 305 | 0 | my ($source, $col) = @_; | |||||||||||||||||||||||||||
| 306 | 0 | my $info = $source->column_info($col); | |||||||||||||||||||||||||||
| 307 | 0 | ▶ | return 0 if $info->{is_auto_increment}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 308 | 0 | ▶ | return 0 if defined $info->{default_value}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 309 | 0 | ▶ | return 0 if $info->{is_nullable}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 310 | 0 | return 1; | |||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | 0 | ▶ | sub _pk_find { | ||||||||||||||||||||||||||
|
Subroutine
_pk_find: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 314 | 0 | my ($ctx, $moniker, $row_hash) = @_; | |||||||||||||||||||||||||||
| 315 | 0 | my $source = $ctx->source($moniker); | |||||||||||||||||||||||||||
| 316 | 0 | my @pk_cols = $source->primary_columns; | |||||||||||||||||||||||||||
| 317 | 0 | my %pk_vals = map { $_ => $row_hash->{$_} } @pk_cols; | |||||||||||||||||||||||||||
| 318 | 0 | ▶ | return unless grep { defined } values %pk_vals == @pk_cols; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 319 | 0 | return $ctx->resultset($moniker)->find(\%pk_vals); | |||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | 0 | ▶ | sub _build_singular_args { | ||||||||||||||||||||||||||
|
Subroutine
_build_singular_args: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 323 | 0 | my ($source) = @_; | |||||||||||||||||||||||||||
| 324 | 0 | my %args; | |||||||||||||||||||||||||||
| 325 | 0 | for my $pk_col ($source->primary_columns) { | |||||||||||||||||||||||||||
| 326 | 0 | $args{$pk_col} = { type => _scalar_for_column($source, $pk_col) }; | |||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||
| 328 | 0 | return \%args; | |||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | 0 | ▶ | sub _build_lookup_args { | ||||||||||||||||||||||||||
|
Subroutine
_build_lookup_args: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||
| 332 | 0 | my ($source) = @_; | |||||||||||||||||||||||||||
| 333 | 0 | my %args; | |||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||
| 335 | 0 | for my $col ($source->primary_columns) { | |||||||||||||||||||||||||||
| 336 | 0 | $args{$col} = { type => _scalar_for_column($source, $col) }; | |||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | 0 | my %unique = $source->unique_constraints; | |||||||||||||||||||||||||||
| 340 | 0 | for my $constraint_name (keys %unique) { | |||||||||||||||||||||||||||
| 341 | 0 | ▶ | next if $constraint_name eq 'primary'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 342 | 0 | for my $col (@{ $unique{$constraint_name} }) { | |||||||||||||||||||||||||||
| 343 | 0 | ▶ | $args{$col} //= { type => _scalar_for_column($source, $col) }; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args{$col} //= {"type", _scalar_for_column($source, $col)}
MC/DC0%0/1
$args{$col} //= {"type", _scalar_for_column($source, $col)}
$args{$col}
Truth table0%0/2
A
A= $args{$col}
| |||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||
| 347 | 0 | return \%args; | |||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||
| 350 | 0 | ▶ | sub _resolve_row { | ||||||||||||||||||||||||||
|
Subroutine
_resolve_row: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||
| 351 | 0 | my ($ctx, $moniker, $args) = @_; | |||||||||||||||||||||||||||
| 352 | 0 | my $source = $ctx->source($moniker); | |||||||||||||||||||||||||||
| 353 | 0 | my $rs = $ctx->resultset($moniker); | |||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||
| 355 | 0 | my @pk_cols = $source->primary_columns; | |||||||||||||||||||||||||||
| 356 | 0 | my @pk_vals = map { $args->{$_} } @pk_cols; | |||||||||||||||||||||||||||
| 357 | 0 | ▶ | unless (grep { !defined } @pk_vals) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 358 | 0 | my $row = $rs->find({ map { $pk_cols[$_] => $pk_vals[$_] } | |||||||||||||||||||||||||||
| 359 | 0 .. $#pk_cols }); | ||||||||||||||||||||||||||||
| 360 | 0 | ▶ | return $row if $row; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||
| 363 | 0 | my %unique = $source->unique_constraints; | |||||||||||||||||||||||||||
| 364 | 0 | for my $constraint_name (sort grep { $_ ne 'primary' } keys %unique) { | |||||||||||||||||||||||||||
| 365 | 0 | my @cols = @{ $unique{$constraint_name} }; | |||||||||||||||||||||||||||
| 366 | 0 | my @vals = map { $args->{$_} } @cols; | |||||||||||||||||||||||||||
| 367 | 0 | ▶ | next if grep { !defined } @vals; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 368 | 0 | my $row = $rs->find({ map { $cols[$_] => $vals[$_] } 0 .. $#cols }); | |||||||||||||||||||||||||||
| 369 | 0 | ▶ | return $row if $row; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | 0 | return undef; | |||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||
| 375 | # | ||||||||||||||||||||||||||||
| 376 | # Cursors are base64(val1:val2:...), stateless, no extra dependencies. | ||||||||||||||||||||||||||||
| 377 | # Colons inside values are percent-encoded so the separator is unambiguous. | ||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||
| 379 | 0 | ▶ | sub _encode_cursor { | ||||||||||||||||||||||||||
|
Subroutine
_encode_cursor: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 380 | 0 | my (@vals) = @_; | |||||||||||||||||||||||||||
| 381 | 0 | my $raw = join ':', map { (my $v = $_) =~ s/%/%25/g; $v =~ s/:/%3A/g; $v } @vals; | |||||||||||||||||||||||||||
| 382 | 0 | return encode_base64($raw, ''); # no newline | |||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | 0 | ▶ | sub _decode_cursor { | ||||||||||||||||||||||||||
|
Subroutine
_decode_cursor: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 386 | 0 | my ($cursor) = @_; | |||||||||||||||||||||||||||
| 387 | 0 | my $raw = decode_base64($cursor); | |||||||||||||||||||||||||||
| 388 | 0 | my @vals = map { (my $v = $_) =~ s/%3A/:/gi; $v =~ s/%25/%/g; $v } | |||||||||||||||||||||||||||
| 389 | split /:/, $raw; | ||||||||||||||||||||||||||||
| 390 | 0 | return @vals; | |||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||
| 393 | # _build_shared_types() | ||||||||||||||||||||||||||||
| 394 | # | ||||||||||||||||||||||||||||
| 395 | # Builds the input/enum types that are shared across all plural queries: | ||||||||||||||||||||||||||||
| 396 | # | ||||||||||||||||||||||||||||
| 397 | # OrderDirection: enum ASC | DESC | ||||||||||||||||||||||||||||
| 398 | # OrderByInput : input { field: String!, direction: OrderDirection } | ||||||||||||||||||||||||||||
| 399 | # PageInput : input { skip: Int, take: Int } | ||||||||||||||||||||||||||||
| 400 | # CursorInput : input { after: String, first: Int } | ||||||||||||||||||||||||||||
| 401 | # | ||||||||||||||||||||||||||||
| 402 | # Returns a hashref of type objects. | ||||||||||||||||||||||||||||
| 403 | 0 | ▶ | sub _build_shared_types { | ||||||||||||||||||||||||||
|
Subroutine
_build_shared_types: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 404 | 0 | my $order_direction = GraphQL::Type::Enum->new( | |||||||||||||||||||||||||||
| 405 | name => 'OrderDirection', | ||||||||||||||||||||||||||||
| 406 | values => { | ||||||||||||||||||||||||||||
| 407 | ASC => { value => 'ASC' }, | ||||||||||||||||||||||||||||
| 408 | DESC => { value => 'DESC' }, | ||||||||||||||||||||||||||||
| 409 | }, | ||||||||||||||||||||||||||||
| 410 | ); | ||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||
| 412 | 0 | my $order_by_input = GraphQL::Type::InputObject->new( | |||||||||||||||||||||||||||
| 413 | name => 'OrderByInput', | ||||||||||||||||||||||||||||
| 414 | fields => { | ||||||||||||||||||||||||||||
| 415 | field => { type => GraphQL::Type::NonNull->new(of => $String) }, | ||||||||||||||||||||||||||||
| 416 | direction => { type => $order_direction }, | ||||||||||||||||||||||||||||
| 417 | }, | ||||||||||||||||||||||||||||
| 418 | ); | ||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||
| 420 | 0 | my $page_input = GraphQL::Type::InputObject->new( | |||||||||||||||||||||||||||
| 421 | name => 'PageInput', | ||||||||||||||||||||||||||||
| 422 | fields => { | ||||||||||||||||||||||||||||
| 423 | skip => { type => $Int }, | ||||||||||||||||||||||||||||
| 424 | take => { type => $Int }, | ||||||||||||||||||||||||||||
| 425 | }, | ||||||||||||||||||||||||||||
| 426 | ); | ||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||
| 428 | 0 | my $cursor_input = GraphQL::Type::InputObject->new( | |||||||||||||||||||||||||||
| 429 | name => 'CursorInput', | ||||||||||||||||||||||||||||
| 430 | fields => { | ||||||||||||||||||||||||||||
| 431 | after => { type => $String }, | ||||||||||||||||||||||||||||
| 432 | first => { type => $Int }, | ||||||||||||||||||||||||||||
| 433 | }, | ||||||||||||||||||||||||||||
| 434 | ); | ||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||
| 436 | return { | ||||||||||||||||||||||||||||
| 437 | 0 | order_direction => $order_direction, | |||||||||||||||||||||||||||
| 438 | order_by_input => $order_by_input, | ||||||||||||||||||||||||||||
| 439 | page_input => $page_input, | ||||||||||||||||||||||||||||
| 440 | cursor_input => $cursor_input, | ||||||||||||||||||||||||||||
| 441 | }; | ||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||
| 444 | # _build_filter_type($source, $moniker) | ||||||||||||||||||||||||||||
| 445 | # | ||||||||||||||||||||||||||||
| 446 | # Builds a per-source InputObject for filtering. For each column we emit: | ||||||||||||||||||||||||||||
| 447 | # col : exact match | ||||||||||||||||||||||||||||
| 448 | # col_not : inequality | ||||||||||||||||||||||||||||
| 449 | # col_like: SQL LIKE (String columns only) | ||||||||||||||||||||||||||||
| 450 | # col_gt / col_gte / col_lt / col_lte: comparisons (Int/Float columns) | ||||||||||||||||||||||||||||
| 451 | # | ||||||||||||||||||||||||||||
| 452 | # Plus recursive AND / OR combinators. | ||||||||||||||||||||||||||||
| 453 | 0 | ▶ | sub _build_filter_type { | ||||||||||||||||||||||||||
|
Subroutine
_build_filter_type: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 454 | 0 | my ($source, $moniker) = @_; | |||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||
| 456 | # We need a forward-declaration trick for the recursive AND/OR fields. | ||||||||||||||||||||||||||||
| 457 | # Create the type object first with an empty fields sub, then fill it in. | ||||||||||||||||||||||||||||
| 458 | my $filter_type = GraphQL::Type::InputObject->new( | ||||||||||||||||||||||||||||
| 459 | name => "${moniker}Filter", | ||||||||||||||||||||||||||||
| 460 | 0 | ▶ | fields => sub { {} }, # placeholder | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 461 | 0 | ); | |||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||
| 463 | 0 | my %fields; | |||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||
| 465 | 0 | for my $col ($source->columns) { | |||||||||||||||||||||||||||
| 466 | 0 | my $scalar = _scalar_for_column($source, $col); | |||||||||||||||||||||||||||
| 467 | 0 | my $name = $scalar->name; | |||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||
| 469 | # exact match | ||||||||||||||||||||||||||||
| 470 | 0 | $fields{$col} = { type => $scalar }; | |||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||
| 472 | # inequality | ||||||||||||||||||||||||||||
| 473 | 0 | $fields{"${col}_not"} = { type => $scalar }; | |||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||
| 475 | 0 | ▶ | if ($name eq 'String') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 476 | # LIKE pattern match (String columns only) | ||||||||||||||||||||||||||||
| 477 | 0 | $fields{"${col}_like"} = { type => $String }; | |||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||
| 479 | else { | ||||||||||||||||||||||||||||
| 480 | # Numeric / boolean comparisons | ||||||||||||||||||||||||||||
| 481 | 0 | $fields{"${col}_gt"} = { type => $scalar }; | |||||||||||||||||||||||||||
| 482 | 0 | $fields{"${col}_gte"} = { type => $scalar }; | |||||||||||||||||||||||||||
| 483 | 0 | $fields{"${col}_lt"} = { type => $scalar }; | |||||||||||||||||||||||||||
| 484 | 0 | $fields{"${col}_lte"} = { type => $scalar }; | |||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||
| 488 | # Recursive AND / OR — each takes a list of the same filter type | ||||||||||||||||||||||||||||
| 489 | 0 | $fields{AND} = { type => GraphQL::Type::List->new(of => $filter_type) }; | |||||||||||||||||||||||||||
| 490 | 0 | $fields{OR} = { type => GraphQL::Type::List->new(of => $filter_type) }; | |||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||
| 492 | # Now replace the placeholder | ||||||||||||||||||||||||||||
| 493 | 0 | ▶ | $filter_type->{fields} = sub { \%fields }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||
| 495 | 0 | return $filter_type; | |||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||
| 498 | # _build_connection_type($moniker, $gql_type) | ||||||||||||||||||||||||||||
| 499 | # | ||||||||||||||||||||||||||||
| 500 | # Builds the per-source connection wrapper returned by plural queries: | ||||||||||||||||||||||||||||
| 501 | # | ||||||||||||||||||||||||||||
| 502 | # type BookConnection { | ||||||||||||||||||||||||||||
| 503 | # nodes: [Book] | ||||||||||||||||||||||||||||
| 504 | # total: Int | ||||||||||||||||||||||||||||
| 505 | # nextCursor: String | ||||||||||||||||||||||||||||
| 506 | # hasNextPage: Boolean | ||||||||||||||||||||||||||||
| 507 | # } | ||||||||||||||||||||||||||||
| 508 | 0 | ▶ | sub _build_connection_type { | ||||||||||||||||||||||||||
|
Subroutine
_build_connection_type: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 509 | 0 | my ($moniker, $gql_type) = @_; | |||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||
| 511 | 0 | return GraphQL::Type::Object->new( | |||||||||||||||||||||||||||
| 512 | name => "${moniker}Connection", | ||||||||||||||||||||||||||||
| 513 | fields => { | ||||||||||||||||||||||||||||
| 514 | nodes => { type => GraphQL::Type::List->new(of => $gql_type) }, | ||||||||||||||||||||||||||||
| 515 | total => { type => $Int }, | ||||||||||||||||||||||||||||
| 516 | nextCursor => { type => $String }, | ||||||||||||||||||||||||||||
| 517 | hasNextPage => { type => $Boolean }, | ||||||||||||||||||||||||||||
| 518 | }, | ||||||||||||||||||||||||||||
| 519 | ); | ||||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||
| 522 | # _filter_to_dbic($filter, $source) | ||||||||||||||||||||||||||||
| 523 | # | ||||||||||||||||||||||||||||
| 524 | # Recursively converts a GraphQL filter hashref into a DBIC search condition. | ||||||||||||||||||||||||||||
| 525 | # | ||||||||||||||||||||||||||||
| 526 | # { title_like: "%Perl%" , OR: [{ id: 1 }, { id: 2 }] } | ||||||||||||||||||||||||||||
| 527 | # => { title => { like => '%Perl%' }, -or => [ { id => 1 }, { id => 2 } ] } | ||||||||||||||||||||||||||||
| 528 | 0 | ▶ | sub _filter_to_dbic { | ||||||||||||||||||||||||||
|
Subroutine
_filter_to_dbic: not called CC=12 SCAR=50.5
| |||||||||||||||||||||||||||||
| 529 | 0 | my ($filter, $source) = @_; | |||||||||||||||||||||||||||
| 530 | 0 | ▶ | return {} unless $filter && %$filter; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$filter and %$filter
MC/DC0%0/2
$filter and %$filter
$filter
%$filter
Truth table0%0/3
A and B
A= $filterB= %$filter
| |||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||
| 532 | 0 | my %cond; | |||||||||||||||||||||||||||
| 533 | my @and_parts; | ||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||
| 535 | # AND / OR combinators | ||||||||||||||||||||||||||||
| 536 | 0 | ▶ | if (my $and = $filter->{AND}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 537 | 0 | push @and_parts, { -and => [ map { _filter_to_dbic($_, $source) } @$and ] }; | |||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||
| 539 | 0 | ▶ | if (my $or = $filter->{OR}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 540 | 0 | push @and_parts, { -or => [ map { _filter_to_dbic($_, $source) } @$or ] }; | |||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||
| 543 | # Column conditions | ||||||||||||||||||||||||||||
| 544 | 0 | for my $key (keys %$filter) { | |||||||||||||||||||||||||||
| 545 | 0 | ▶ | next if $key eq 'AND' || $key eq 'OR'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$key eq "AND" or $key eq "OR"
MC/DC0%0/2
$key eq "AND" or $key eq "OR"
$key eq "AND"
$key eq "OR"
Truth table0%0/3
A or B
A= $key eq "AND"B= $key eq "OR"
| |||||||||||||||||||||||||||||
| 546 | 0 | ▶ | next unless defined $filter->{$key}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||
| 548 | 0 | ▶ | if ($key =~ /^(.+)_(not|like|gt|gte|lt|lte)$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 549 | 0 | my ($col, $op) = ($1, $2); | |||||||||||||||||||||||||||
| 550 | my $dbic_op = { not => '!=' , like => 'like', | ||||||||||||||||||||||||||||
| 551 | gt => '>' , gte => '>=', | ||||||||||||||||||||||||||||
| 552 | 0 | lt => '<' , lte => '<=' }->{$op}; | |||||||||||||||||||||||||||
| 553 | 0 | push @and_parts, { $col => { $dbic_op => $filter->{$key} } }; | |||||||||||||||||||||||||||
| 554 | } | ||||||||||||||||||||||||||||
| 555 | else { | ||||||||||||||||||||||||||||
| 556 | # exact match | ||||||||||||||||||||||||||||
| 557 | 0 | push @and_parts, { $key => $filter->{$key} }; | |||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||
| 561 | 0 | ▶ | return @and_parts == 1 ? $and_parts[0] | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 562 | : @and_parts > 1 ? { -and => \@and_parts } | ||||||||||||||||||||||||||||
| 563 | : {}; | ||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||
| 566 | # _apply_pagination($rs, $args, $source) | ||||||||||||||||||||||||||||
| 567 | # | ||||||||||||||||||||||||||||
| 568 | # Applies ordering, then either offset (page) or cursor (cursor) pagination. | ||||||||||||||||||||||||||||
| 569 | # Returns ($paged_rs, $next_cursor, $has_next_page). | ||||||||||||||||||||||||||||
| 570 | # | ||||||||||||||||||||||||||||
| 571 | # Precedence: cursor pagination wins if both are supplied. | ||||||||||||||||||||||||||||
| 572 | 0 | ▶ | sub _apply_pagination { | ||||||||||||||||||||||||||
|
Subroutine
_apply_pagination: not called CC=16 SCAR=56.1
| |||||||||||||||||||||||||||||
| 573 | 0 | my ($rs, $args, $source) = @_; | |||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||
| 575 | 0 | my @pk_cols = $source->primary_columns; | |||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||
| 577 | # Ordering | ||||||||||||||||||||||||||||
| 578 | 0 | my $order_by = $args->{orderBy}; | |||||||||||||||||||||||||||
| 579 | 0 | ▶ | if ($order_by && $order_by->{field}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$order_by and $order_by->{"field"}
MC/DC0%0/2
$order_by and $order_by->{"field"}
$order_by
$order_by->{"field"}
Truth table0%0/3
A and B
A= $order_byB= $order_by->{"field"}
| |||||||||||||||||||||||||||||
| 580 | 0 | my $field = $order_by->{field}; | |||||||||||||||||||||||||||
| 581 | 0 | ▶ | if ( $source->has_column($field) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 582 | 0 | ▶ | my $dir = lc($order_by->{direction} // 'ASC'); | ||||||||||||||||||||||||||
|
Condition0%0/2
$order_by->{"direction"} // "ASC"
MC/DC0%0/1
$order_by->{"direction"} // "ASC"
$order_by->{"direction"}
Truth table0%0/2
A
A= $order_by->{"direction"}
| |||||||||||||||||||||||||||||
| 583 | 0 | $rs = $rs->search(undef, { order_by => { "-$dir" => $field } }); | |||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||
| 585 | else { | ||||||||||||||||||||||||||||
| 586 | 0 | die "Invalid field '$field' provided for orderBy.\n"; | |||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||
| 589 | else { | ||||||||||||||||||||||||||||
| 590 | # Default: stable order by PK | ||||||||||||||||||||||||||||
| 591 | 0 | $rs = $rs->search(undef, { order_by => [ map { { -asc => $_ } } @pk_cols ] }); | |||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||
| 594 | # Cursor pagination | ||||||||||||||||||||||||||||
| 595 | 0 | ▶ | if (my $cursor_args = $args->{cursor}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 596 | 0 | ▶ | my $first = $cursor_args->{first} // 10; | ||||||||||||||||||||||||||
|
Condition0%0/2
$cursor_args->{"first"} // 10
MC/DC0%0/1
$cursor_args->{"first"} // 10
$cursor_args->{"first"}
Truth table0%0/2
A
A= $cursor_args->{"first"}
| |||||||||||||||||||||||||||||
| 597 | 0 | my $after = $cursor_args->{after}; | |||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||
| 599 | 0 | ▶ | if ($after) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 600 | 0 | my @decoded = _decode_cursor($after); | |||||||||||||||||||||||||||
| 601 | 0 | ▶ | if (@pk_cols == 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 602 | # Simple: WHERE pk > cursor_val (works for ordered-by-PK default) | ||||||||||||||||||||||||||||
| 603 | 0 | $rs = $rs->search({ $pk_cols[0] => { '>' => $decoded[0] } }); | |||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||
| 605 | else { | ||||||||||||||||||||||||||||
| 606 | # Composite PK: fetch everything after decoded position | ||||||||||||||||||||||||||||
| 607 | # by re-applying a compound condition | ||||||||||||||||||||||||||||
| 608 | 0 | my %after_cond = map { $pk_cols[$_] => { '>' => $decoded[$_] } } | |||||||||||||||||||||||||||
| 609 | 0 .. $#pk_cols; | ||||||||||||||||||||||||||||
| 610 | 0 | $rs = $rs->search(\%after_cond); | |||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||
| 612 | } | ||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||
| 614 | # Fetch one extra to detect hasNextPage | ||||||||||||||||||||||||||||
| 615 | 0 | my @rows = $rs->search(undef, { rows => $first + 1 })->all; | |||||||||||||||||||||||||||
| 616 | 0 | my $has_next = @rows > $first; | |||||||||||||||||||||||||||
| 617 | 0 | ▶ | @rows = @rows[0 .. $first - 1] if $has_next; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||
| 619 | 0 | my $next_cursor; | |||||||||||||||||||||||||||
| 620 | 0 | ▶ | if ($has_next && @rows) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$has_next and @rows
MC/DC0%0/2
$has_next and @rows
$has_next
@rows
Truth table0%0/3
A and B
A= $has_nextB= @rows
| |||||||||||||||||||||||||||||
| 621 | 0 | my $last_row = $rows[-1]; | |||||||||||||||||||||||||||
| 622 | 0 | $next_cursor = _encode_cursor(map { $last_row->get_column($_) } @pk_cols); | |||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||
| 625 | return ( | ||||||||||||||||||||||||||||
| 626 | 0 | ▶ | [ map { { $_->get_columns } } @rows ], | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 627 | $next_cursor, | ||||||||||||||||||||||||||||
| 628 | $has_next ? 1 : 0, | ||||||||||||||||||||||||||||
| 629 | ); | ||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||
| 632 | # Offset pagination | ||||||||||||||||||||||||||||
| 633 | 0 | ▶ | if (my $page_args = $args->{page}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 634 | 0 | ▶ | my $skip = $page_args->{skip} // 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
$page_args->{"skip"} // 0
MC/DC0%0/1
$page_args->{"skip"} // 0
$page_args->{"skip"}
Truth table0%0/2
A
A= $page_args->{"skip"}
| |||||||||||||||||||||||||||||
| 635 | 0 | ▶ | my $take = $page_args->{take} // 10; | ||||||||||||||||||||||||||
|
Condition0%0/2
$page_args->{"take"} // 10
MC/DC0%0/1
$page_args->{"take"} // 10
$page_args->{"take"}
Truth table0%0/2
A
A= $page_args->{"take"}
| |||||||||||||||||||||||||||||
| 636 | 0 | my @rows = $rs->search(undef, { rows => $take, offset => $skip })->all; | |||||||||||||||||||||||||||
| 637 | return ( | ||||||||||||||||||||||||||||
| 638 | 0 | [ map { { $_->get_columns } } @rows ], | |||||||||||||||||||||||||||
| 639 | undef, # no cursor for offset pagination | ||||||||||||||||||||||||||||
| 640 | 0, | ||||||||||||||||||||||||||||
| 641 | ); | ||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||
| 644 | # No pagination: return everything | ||||||||||||||||||||||||||||
| 645 | 0 | my @rows = $rs->all; | |||||||||||||||||||||||||||
| 646 | return ( | ||||||||||||||||||||||||||||
| 647 | 0 | [ map { { $_->get_columns } } @rows ], | |||||||||||||||||||||||||||
| 648 | undef, | ||||||||||||||||||||||||||||
| 649 | 0, | ||||||||||||||||||||||||||||
| 650 | ); | ||||||||||||||||||||||||||||
| 651 | } | ||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||
| 653 | 0 | ▶ | sub _build_mutation_fields { | ||||||||||||||||||||||||||
|
Subroutine
_build_mutation_fields: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 654 | 0 | my ($source, $moniker, $gql_type) = @_; | |||||||||||||||||||||||||||
| 655 | 0 | my %fields; | |||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||
| 657 | 0 | my @pk_cols = $source->primary_columns; | |||||||||||||||||||||||||||
| 658 | 0 | my %is_pk = map { $_ => 1 } @pk_cols; | |||||||||||||||||||||||||||
| 659 | 0 | my @all_cols = $source->columns; | |||||||||||||||||||||||||||
| 660 | 0 | my @data_cols = grep { !$is_pk{$_} } @all_cols; | |||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||
| 662 | # createX | ||||||||||||||||||||||||||||
| 663 | 0 | my %create_args; | |||||||||||||||||||||||||||
| 664 | 0 | for my $col (@all_cols) { | |||||||||||||||||||||||||||
| 665 | 0 | my $scalar = _scalar_for_column($source, $col); | |||||||||||||||||||||||||||
| 666 | 0 | ▶ | $create_args{$col} = { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 667 | type => _col_is_required($source, $col) | ||||||||||||||||||||||||||||
| 668 | ? GraphQL::Type::NonNull->new(of => $scalar) | ||||||||||||||||||||||||||||
| 669 | : $scalar, | ||||||||||||||||||||||||||||
| 670 | }; | ||||||||||||||||||||||||||||
| 671 | } | ||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||
| 673 | $fields{ 'create' . ucfirst($moniker) } = { | ||||||||||||||||||||||||||||
| 674 | type => $gql_type, | ||||||||||||||||||||||||||||
| 675 | args => \%create_args, | ||||||||||||||||||||||||||||
| 676 | description => "Insert a new $moniker row. Required columns are marked non-null.", | ||||||||||||||||||||||||||||
| 677 | 0 | ▶ | resolve => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 678 | 0 | my ($root, $args, $ctx) = @_; | |||||||||||||||||||||||||||
| 679 | 0 | my %data = map { $_ => $args->{$_} } | |||||||||||||||||||||||||||
| 680 | 0 | grep { defined $args->{$_} } keys %$args; | |||||||||||||||||||||||||||
| 681 | 0 | my $row = eval { $ctx->resultset($moniker)->create(\%data) }; | |||||||||||||||||||||||||||
| 682 | 0 | ▶ | die $@ if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 683 | 0 | return { $row->get_columns }; | |||||||||||||||||||||||||||
| 684 | }, | ||||||||||||||||||||||||||||
| 685 | 0 | }; | |||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||
| 687 | # updateX — full replacement; all non-key columns should be supplied. | ||||||||||||||||||||||||||||
| 688 | 0 | my %update_lookup_args = %{ _build_lookup_args($source) }; | |||||||||||||||||||||||||||
| 689 | my %update_data_args = map { | ||||||||||||||||||||||||||||
| 690 | 0 | $_ => { type => _scalar_for_column($source, $_) } | |||||||||||||||||||||||||||
| 691 | } @data_cols; | ||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||
| 693 | $fields{ 'update' . ucfirst($moniker) } = { | ||||||||||||||||||||||||||||
| 694 | type => $gql_type, | ||||||||||||||||||||||||||||
| 695 | args => { %update_lookup_args, %update_data_args }, | ||||||||||||||||||||||||||||
| 696 | description => "Full update of a $moniker row identified by its primary key " | ||||||||||||||||||||||||||||
| 697 | . "or any unique constraint. All non-key columns should be " | ||||||||||||||||||||||||||||
| 698 | . "supplied; omitted columns are left unchanged in the database " | ||||||||||||||||||||||||||||
| 699 | . "but that is incidental — use patchX for intentional sparse updates.", | ||||||||||||||||||||||||||||
| 700 | 0 | ▶ | resolve => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 701 | 0 | my ($root, $args, $ctx) = @_; | |||||||||||||||||||||||||||
| 702 | 0 | my $row = _resolve_row($ctx, $moniker, $args); | |||||||||||||||||||||||||||
| 703 | 0 | ▶ | die "No $moniker row found for the supplied key(s)\n" unless $row; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 704 | 0 | my %data = map { $_ => $args->{$_} } | |||||||||||||||||||||||||||
| 705 | 0 | ▶ | grep { !$is_pk{$_} && defined $args->{$_} } keys %$args; | ||||||||||||||||||||||||||
|
Condition0%0/3
!$is_pk{$_} && defined $args->{$_}
MC/DC0%0/2
!$is_pk{$_} && defined $args->{$_}
!$is_pk{$_}
defined $args->{$_}
Truth table0%0/3
not(A) && B
A= !$is_pk{$_}B= defined $args->{$_}
| |||||||||||||||||||||||||||||
| 706 | 0 | $row = eval { $row->update(\%data); $row->discard_changes; $row }; | |||||||||||||||||||||||||||
| 707 | 0 | ▶ | die $@ if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 708 | 0 | return { $row->get_columns }; | |||||||||||||||||||||||||||
| 709 | }, | ||||||||||||||||||||||||||||
| 710 | 0 | }; | |||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||
| 712 | # patchX — sparse update; only columns explicitly provided are changed. | ||||||||||||||||||||||||||||
| 713 | # Identified by primary key or any unique constraint, same as updateX. | ||||||||||||||||||||||||||||
| 714 | # Every non-key column is optional (nullable). Only defined arguments | ||||||||||||||||||||||||||||
| 715 | # are sent to ->update(), so the caller can safely omit any column they | ||||||||||||||||||||||||||||
| 716 | # do not wish to change. | ||||||||||||||||||||||||||||
| 717 | $fields{ 'patch' . ucfirst($moniker) } = { | ||||||||||||||||||||||||||||
| 718 | type => $gql_type, | ||||||||||||||||||||||||||||
| 719 | args => { %update_lookup_args, %update_data_args }, | ||||||||||||||||||||||||||||
| 720 | description => "Sparse update of a $moniker row identified by its primary key " | ||||||||||||||||||||||||||||
| 721 | . "or any unique constraint. Supply only the columns you want " | ||||||||||||||||||||||||||||
| 722 | . "to change; all other columns are left untouched.", | ||||||||||||||||||||||||||||
| 723 | 0 | ▶ | resolve => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 724 | 0 | my ($root, $args, $ctx) = @_; | |||||||||||||||||||||||||||
| 725 | 0 | my $row = _resolve_row($ctx, $moniker, $args); | |||||||||||||||||||||||||||
| 726 | 0 | ▶ | die "No $moniker row found for the supplied key(s)\n" unless $row; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 727 | # Only send columns the client explicitly provided. | ||||||||||||||||||||||||||||
| 728 | # GraphQL omits absent args from the hash entirely, so a | ||||||||||||||||||||||||||||
| 729 | # defined-check is sufficient to distinguish "not sent" from null. | ||||||||||||||||||||||||||||
| 730 | 0 | my %data = map { $_ => $args->{$_} } | |||||||||||||||||||||||||||
| 731 | 0 | ▶ | grep { !$is_pk{$_} && defined $args->{$_} } keys %$args; | ||||||||||||||||||||||||||
|
Condition0%0/3
!$is_pk{$_} && defined $args->{$_}
MC/DC0%0/2
!$is_pk{$_} && defined $args->{$_}
!$is_pk{$_}
defined $args->{$_}
Truth table0%0/3
not(A) && B
A= !$is_pk{$_}B= defined $args->{$_}
| |||||||||||||||||||||||||||||
| 732 | 0 | ▶ | die "patchX: no non-key columns supplied — nothing to update\n" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 733 | unless %data; | ||||||||||||||||||||||||||||
| 734 | 0 | $row = eval { $row->update(\%data); $row->discard_changes; $row }; | |||||||||||||||||||||||||||
| 735 | 0 | ▶ | die $@ if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 736 | 0 | return { $row->get_columns }; | |||||||||||||||||||||||||||
| 737 | }, | ||||||||||||||||||||||||||||
| 738 | 0 | }; | |||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||
| 740 | # deleteX | ||||||||||||||||||||||||||||
| 741 | $fields{ 'delete' . ucfirst($moniker) } = { | ||||||||||||||||||||||||||||
| 742 | type => $Boolean, | ||||||||||||||||||||||||||||
| 743 | args => _build_lookup_args($source), | ||||||||||||||||||||||||||||
| 744 | description => "Delete a $moniker row identified by its primary key " | ||||||||||||||||||||||||||||
| 745 | . "or any unique constraint. Returns true on success.", | ||||||||||||||||||||||||||||
| 746 | 0 | ▶ | resolve => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 747 | 0 | my ($root, $args, $ctx) = @_; | |||||||||||||||||||||||||||
| 748 | 0 | my $row = _resolve_row($ctx, $moniker, $args); | |||||||||||||||||||||||||||
| 749 | 0 | ▶ | return 0 unless $row; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 750 | 0 | eval { $row->delete }; | |||||||||||||||||||||||||||
| 751 | 0 | ▶ | return $@ ? 0 : 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 752 | }, | ||||||||||||||||||||||||||||
| 753 | 0 | }; | |||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||
| 755 | 0 | return %fields; | |||||||||||||||||||||||||||
| 756 | } | ||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||
| 758 | =head1 SCALAR TYPE MAPPING | ||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||
| 760 | SQL column types are mapped to GraphQL scalars in the following priority order: | ||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||
| 762 | Boolean: bool, boolean, tinyint(1) | ||||||||||||||||||||||||||||
| 763 | Float : float, double, double precision, real, money, decimal, numeric | ||||||||||||||||||||||||||||
| 764 | Int : int, integer, bigint, smallint, tinyint, mediumint, serial | ||||||||||||||||||||||||||||
| 765 | String : everything else (safe fallback) | ||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||
| 767 | =head1 PLURAL QUERIES | ||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||
| 769 | Every source C<X> gets an C<allXs> query returning an C<XConnection>: | ||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||
| 771 | type XConnection { | ||||||||||||||||||||||||||||
| 772 | nodes: [X] | ||||||||||||||||||||||||||||
| 773 | total: Int # total rows matching filter, before pagination | ||||||||||||||||||||||||||||
| 774 | nextCursor: String # opaque cursor; set only during cursor pagination | ||||||||||||||||||||||||||||
| 775 | hasNextPage: Boolean # true when more pages follow | ||||||||||||||||||||||||||||
| 776 | } | ||||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||
| 778 | Always request C<total> or another scalar field alongside C<nodes> in your | ||||||||||||||||||||||||||||
| 779 | selection set - see L</KNOWN BEHAVIOUR>. | ||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||
| 781 | =head2 Filtering | ||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||
| 783 | allBooks(filter: { title_like: "%Perl%", author_id: 3 }) { | ||||||||||||||||||||||||||||
| 784 | total nodes { title } | ||||||||||||||||||||||||||||
| 785 | } | ||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||
| 787 | Per-column operators: | ||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||
| 789 | col exact match | ||||||||||||||||||||||||||||
| 790 | col_not inequality (!=) | ||||||||||||||||||||||||||||
| 791 | col_like LIKE pattern (String columns only) | ||||||||||||||||||||||||||||
| 792 | col_gt greater than | ||||||||||||||||||||||||||||
| 793 | col_gte greater than or equal | ||||||||||||||||||||||||||||
| 794 | col_lt less than | ||||||||||||||||||||||||||||
| 795 | col_lte less than or equal | ||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||
| 797 | Logical combinators (nest recursively and combine freely): | ||||||||||||||||||||||||||||
| 798 | |||||||||||||||||||||||||||||
| 799 | allBooks(filter: { | ||||||||||||||||||||||||||||
| 800 | AND: [ | ||||||||||||||||||||||||||||
| 801 | { author_id: 1 } | ||||||||||||||||||||||||||||
| 802 | { OR: [{ title_like: "%Hobbit%" }, { title_like: "%Ring%" }] } | ||||||||||||||||||||||||||||
| 803 | ] | ||||||||||||||||||||||||||||
| 804 | }) { total nodes { title } } | ||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||
| 806 | =head2 Ordering | ||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||
| 808 | allBooks(orderBy: { field: "title", direction: ASC }) { | ||||||||||||||||||||||||||||
| 809 | total nodes { title } | ||||||||||||||||||||||||||||
| 810 | } | ||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||
| 812 | C<direction> is the C<OrderDirection> enum: C<ASC> or C<DESC>. When omitted, | ||||||||||||||||||||||||||||
| 813 | results are ordered by primary key ascending. | ||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||
| 815 | =head2 Offset pagination | ||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||
| 817 | allBooks(page: { skip: 10, take: 5 }) { total nodes { title } } | ||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||
| 819 | C<skip> defaults to 0, C<take> defaults to 10. | ||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||
| 821 | =head2 Cursor pagination | ||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||
| 823 | # First page | ||||||||||||||||||||||||||||
| 824 | allBooks(cursor: { first: 5 }) { | ||||||||||||||||||||||||||||
| 825 | total nextCursor hasNextPage nodes { title } | ||||||||||||||||||||||||||||
| 826 | } | ||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||
| 828 | # Subsequent pages - pass nextCursor from the previous response | ||||||||||||||||||||||||||||
| 829 | allBooks(cursor: { after: "...", first: 5 }) { | ||||||||||||||||||||||||||||
| 830 | total nextCursor hasNextPage nodes { title } | ||||||||||||||||||||||||||||
| 831 | } | ||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||
| 833 | C<first> defaults to 10. Cursor pagination takes precedence over offset | ||||||||||||||||||||||||||||
| 834 | pagination if both are supplied in the same query. Cursors are opaque | ||||||||||||||||||||||||||||
| 835 | base64-encoded strings derived from the row's primary key and should be | ||||||||||||||||||||||||||||
| 836 | treated as implementation details subject to change. | ||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||
| 838 | =head1 MUTATIONS | ||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||
| 840 | For every source C<X>, four mutations are generated: | ||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||
| 842 | =head2 createX | ||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||
| 844 | mutation { createBook(title: "Dune", author_id: 4) { id title } } | ||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||
| 846 | Accepts all column values as arguments. Columns that are non-nullable, | ||||||||||||||||||||||||||||
| 847 | have no declared default, and are not auto-increment are wrapped in | ||||||||||||||||||||||||||||
| 848 | C<NonNull> and must be supplied. On failure, C<die>s - the error appears | ||||||||||||||||||||||||||||
| 849 | in the top-level C<errors> array of the response. | ||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||
| 851 | =head2 updateX | ||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||
| 853 | mutation { updateBook(id: 1, title: "Dune Messiah", author_id: 4) { id title } } | ||||||||||||||||||||||||||||
| 854 | |||||||||||||||||||||||||||||
| 855 | Full update. Identifies the target row by its primary key B<or> by a | ||||||||||||||||||||||||||||
| 856 | complete set of columns from any unique constraint declared on the source. | ||||||||||||||||||||||||||||
| 857 | All non-key columns should be supplied. C<die>s if the row cannot be found | ||||||||||||||||||||||||||||
| 858 | or the update fails. | ||||||||||||||||||||||||||||
| 859 | |||||||||||||||||||||||||||||
| 860 | Use C<patchX> when you only want to change a subset of columns. | ||||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||
| 862 | =head2 patchX | ||||||||||||||||||||||||||||
| 863 | |||||||||||||||||||||||||||||
| 864 | mutation { patchBook(id: 1, title: "Dune Messiah") { id title } } | ||||||||||||||||||||||||||||
| 865 | |||||||||||||||||||||||||||||
| 866 | Sparse (partial) update. Identifies the target row the same way as | ||||||||||||||||||||||||||||
| 867 | C<updateX> (primary key or unique constraint), but only the non-key columns | ||||||||||||||||||||||||||||
| 868 | you explicitly supply are written to the database. Any column you omit is | ||||||||||||||||||||||||||||
| 869 | left exactly as it is. | ||||||||||||||||||||||||||||
| 870 | |||||||||||||||||||||||||||||
| 871 | # Change only the title - author_id is untouched | ||||||||||||||||||||||||||||
| 872 | mutation { patchBook(id: 1, title: "Dune Messiah") { id title author { name } } } | ||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||
| 874 | # Change only the foreign key - title is untouched | ||||||||||||||||||||||||||||
| 875 | mutation { patchBook(id: 1, author_id: 2) { id title author { name } } } | ||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||
| 877 | C<die>s if the row cannot be found, the update fails, or no non-key | ||||||||||||||||||||||||||||
| 878 | columns are supplied at all. | ||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||
| 880 | =head2 deleteX | ||||||||||||||||||||||||||||
| 881 | |||||||||||||||||||||||||||||
| 882 | mutation { deleteBook(id: 1) } | ||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||
| 884 | Identifies the target row by primary key or unique constraint. Returns | ||||||||||||||||||||||||||||
| 885 | C<true> (C<Boolean>) on success, C<false> if the row is not found. | ||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||
| 887 | =head1 ERROR HANDLING | ||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||
| 889 | C<createX> and C<updateX> resolver failures C<die>. GraphQL catches the | ||||||||||||||||||||||||||||
| 890 | exception and surfaces it in the top-level C<errors> array; the C<data> | ||||||||||||||||||||||||||||
| 891 | field for the failed mutation will be C<null>. C<deleteX> returns C<false> | ||||||||||||||||||||||||||||
| 892 | rather than dying when a row is not found. | ||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||
| 894 | =head1 LIMITATIONS | ||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||
| 896 | =over 4 | ||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||
| 898 | =item * B<Relationship fields are unfiltered.> Relationship fields within a | ||||||||||||||||||||||||||||
| 899 | query (e.g. C<author { books { title } }>) return all related rows. They do | ||||||||||||||||||||||||||||
| 900 | not accept C<filter>, C<orderBy>, or pagination arguments. | ||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||
| 902 | =item * B<No nested input for mutations.> C<createX> and C<updateX> accept | ||||||||||||||||||||||||||||
| 903 | only scalar column values. Related rows must be created or linked separately | ||||||||||||||||||||||||||||
| 904 | using their own mutations and raw foreign-key values. | ||||||||||||||||||||||||||||
| 905 | |||||||||||||||||||||||||||||
| 906 | =item * B<updateX is a full update.> All non-primary-key columns should be | ||||||||||||||||||||||||||||
| 907 | supplied; use C<patchX> for intentional sparse / partial updates. | ||||||||||||||||||||||||||||
| 908 | |||||||||||||||||||||||||||||
| 909 | =item * B<Cursor pagination assumes primary-key order.> The C<after> cursor | ||||||||||||||||||||||||||||
| 910 | encodes the primary key of the last returned row and applies a | ||||||||||||||||||||||||||||
| 911 | C<pk E<gt> value> condition. If you supply a custom C<orderBy> using a | ||||||||||||||||||||||||||||
| 912 | non-primary-key column, the cursor will not advance correctly. Use offset | ||||||||||||||||||||||||||||
| 913 | pagination (C<page>) when ordering by non-PK columns. | ||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||
| 915 | =item * B<No custom scalars.> Column types such as C<date>, C<datetime>, | ||||||||||||||||||||||||||||
| 916 | C<json>, and C<uuid> all map to C<String>. Custom GraphQL scalars are not | ||||||||||||||||||||||||||||
| 917 | generated. | ||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||
| 919 | =item * B<No subscriptions.> Only C<Query> and C<Mutation> operation types | ||||||||||||||||||||||||||||
| 920 | are generated. | ||||||||||||||||||||||||||||
| 921 | |||||||||||||||||||||||||||||
| 922 | =item * B<C<col_like> case sensitivity is database-dependent.> SQLite | ||||||||||||||||||||||||||||
| 923 | C<LIKE> is case-insensitive for ASCII characters but case-sensitive for | ||||||||||||||||||||||||||||
| 924 | Unicode. PostgreSQL C<LIKE> is always case-sensitive. Use C<col_like> | ||||||||||||||||||||||||||||
| 925 | accordingly. | ||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||
| 927 | =back | ||||||||||||||||||||||||||||
| 928 | |||||||||||||||||||||||||||||
| 929 | =head1 KNOWN BEHAVIOUR | ||||||||||||||||||||||||||||
| 930 | |||||||||||||||||||||||||||||
| 931 | When querying a plural C<allXs> field, always include at least one scalar | ||||||||||||||||||||||||||||
| 932 | field (C<total>, C<hasNextPage>, or C<nextCursor>) alongside C<nodes> in | ||||||||||||||||||||||||||||
| 933 | your selection set: | ||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||
| 935 | # Correct | ||||||||||||||||||||||||||||
| 936 | { allBooks { total nodes { title } } } | ||||||||||||||||||||||||||||
| 937 | |||||||||||||||||||||||||||||
| 938 | # May silently return empty nodes in some GraphQL executor versions | ||||||||||||||||||||||||||||
| 939 | { allBooks { nodes { title } } } | ||||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||
| 941 | This is a quirk of how C<GraphQL::Execution> resolves connection object | ||||||||||||||||||||||||||||
| 942 | types when the selection set contains only a list field. | ||||||||||||||||||||||||||||
| 943 | |||||||||||||||||||||||||||||
| 944 | =head1 DEPENDENCIES | ||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||
| 946 | L<DBIx::Class>, L<GraphQL::Schema>, L<GraphQL::Type::Object>, | ||||||||||||||||||||||||||||
| 947 | L<GraphQL::Type::InputObject>, L<GraphQL::Type::List>, | ||||||||||||||||||||||||||||
| 948 | L<GraphQL::Type::NonNull>, L<GraphQL::Type::Enum>, | ||||||||||||||||||||||||||||
| 949 | L<GraphQL::Type::Scalar>, L<MIME::Base64> (core). | ||||||||||||||||||||||||||||
| 950 | |||||||||||||||||||||||||||||
| 951 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||
| 953 | L<GraphQL::Plugin::Convert::DBIC>, L<DBIx::Class::Schema>, L<GraphQL::Schema> | ||||||||||||||||||||||||||||
| 954 | |||||||||||||||||||||||||||||
| 955 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||
| 957 | Mohammad Sajid Anwar, C<< <mohammad.anwar at yahoo.com> >> | ||||||||||||||||||||||||||||
| 958 | |||||||||||||||||||||||||||||
| 959 | =head1 REPOSITORY | ||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||
| 961 | L<https://github.com/manwar/DBIx-Class-Schema-GraphQL> | ||||||||||||||||||||||||||||
| 962 | |||||||||||||||||||||||||||||
| 963 | =head1 BUGS | ||||||||||||||||||||||||||||
| 964 | |||||||||||||||||||||||||||||
| 965 | Please report any bugs or feature requests through the web interface at L<https://github.com/manwar/DBIx-Class-Schema-GraphQL/issues>. | ||||||||||||||||||||||||||||
| 966 | I will be notified and then you'll automatically be notified of progress on your | ||||||||||||||||||||||||||||
| 967 | bug as I make changes. | ||||||||||||||||||||||||||||
| 968 | |||||||||||||||||||||||||||||
| 969 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 970 | |||||||||||||||||||||||||||||
| 971 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||
| 972 | |||||||||||||||||||||||||||||
| 973 | perldoc DBix::Class::Schema::GraphQL | ||||||||||||||||||||||||||||
| 974 | |||||||||||||||||||||||||||||
| 975 | You can also look for information at: | ||||||||||||||||||||||||||||
| 976 | |||||||||||||||||||||||||||||
| 977 | =over 4 | ||||||||||||||||||||||||||||
| 978 | |||||||||||||||||||||||||||||
| 979 | =item * BUG Report | ||||||||||||||||||||||||||||
| 980 | |||||||||||||||||||||||||||||
| 981 | L<https://github.com/manwar/DBIx-Class-Schema-GraphQL/issues> | ||||||||||||||||||||||||||||
| 982 | |||||||||||||||||||||||||||||
| 983 | =item * CPAN Ratings | ||||||||||||||||||||||||||||
| 984 | |||||||||||||||||||||||||||||
| 985 | L<http://cpanratings.perl.org/d/DBIx-Class-Schema-GraphQL> | ||||||||||||||||||||||||||||
| 986 | |||||||||||||||||||||||||||||
| 987 | =item * Search MetaCPAN | ||||||||||||||||||||||||||||
| 988 | |||||||||||||||||||||||||||||
| 989 | L<https://metacpan.org/dist/DBIx-Class-Schema-GraphQL> | ||||||||||||||||||||||||||||
| 990 | |||||||||||||||||||||||||||||
| 991 | =back | ||||||||||||||||||||||||||||
| 992 | |||||||||||||||||||||||||||||
| 993 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||
| 994 | |||||||||||||||||||||||||||||
| 995 | Copyright (C) 2026 Mohammad Sajid Anwar. | ||||||||||||||||||||||||||||
| 996 | |||||||||||||||||||||||||||||
| 997 | This program is free software; you can redistribute it and / or modify it under | ||||||||||||||||||||||||||||
| 998 | the terms of the the Artistic License (2.0). You may obtain a copy of the full | ||||||||||||||||||||||||||||
| 999 | license at: | ||||||||||||||||||||||||||||
| 1000 | |||||||||||||||||||||||||||||
| 1001 | L<http://www.perlfoundation.org/artistic_license_2_0> | ||||||||||||||||||||||||||||
| 1002 | |||||||||||||||||||||||||||||
| 1003 | Any use, modification, and distribution of the Standard or Modified Versions is | ||||||||||||||||||||||||||||
| 1004 | governed by this Artistic License.By using, modifying or distributing the Package, | ||||||||||||||||||||||||||||
| 1005 | you accept this license. Do not use, modify, or distribute the Package, if you do | ||||||||||||||||||||||||||||
| 1006 | not accept this license. | ||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||
| 1008 | If your Modified Version has been derived from a Modified Version made by someone | ||||||||||||||||||||||||||||
| 1009 | other than you,you are nevertheless required to ensure that your Modified Version | ||||||||||||||||||||||||||||
| 1010 | complies with the requirements of this license. | ||||||||||||||||||||||||||||
| 1011 | |||||||||||||||||||||||||||||
| 1012 | This license does not grant you the right to use any trademark, service mark, | ||||||||||||||||||||||||||||
| 1013 | tradename, or logo of the Copyright Holder. | ||||||||||||||||||||||||||||
| 1014 | |||||||||||||||||||||||||||||
| 1015 | This license includes the non-exclusive, worldwide, free-of-charge patent license | ||||||||||||||||||||||||||||
| 1016 | to make, have made, use, offer to sell, sell, import and otherwise transfer the | ||||||||||||||||||||||||||||
| 1017 | Package with respect to any patent claims licensable by the Copyright Holder that | ||||||||||||||||||||||||||||
| 1018 | are necessarily infringed by the Package. If you institute patent litigation | ||||||||||||||||||||||||||||
| 1019 | (including a cross-claim or counterclaim) against any party alleging that the | ||||||||||||||||||||||||||||
| 1020 | Package constitutes direct or contributory patent infringement,then this Artistic | ||||||||||||||||||||||||||||
| 1021 | License to you shall terminate on the date that such litigation is filed. | ||||||||||||||||||||||||||||
| 1022 | |||||||||||||||||||||||||||||
| 1023 | Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND | ||||||||||||||||||||||||||||
| 1024 | CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED | ||||||||||||||||||||||||||||
| 1025 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR | ||||||||||||||||||||||||||||
| 1026 | NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS | ||||||||||||||||||||||||||||
| 1027 | REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, | ||||||||||||||||||||||||||||
| 1028 | INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE | ||||||||||||||||||||||||||||
| 1029 | OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||||||||||||||||||||||||
| 1030 | |||||||||||||||||||||||||||||
| 1031 | =cut | ||||||||||||||||||||||||||||
| 1032 | |||||||||||||||||||||||||||||
| 1033 | 8 | 1; # End of DBIx::Class::Schema::GraphQL | |||||||||||||||||||||||||||