| 1 | package GraphQL::Role::Nullable; | ||
| 2 | |||
| 3 | 18 | ▶ | use 5.014; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 18 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 18 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 18 | ▶ | use Types::Standard -all; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 18 | ▶ | use Moo::Role; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 18 | ▶ | use GraphQL::Type::NonNull; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 8 | our $VERSION = '0.02'; | |
| 11 | |||
| 12 | =head1 NAME | ||
| 13 | |||
| 14 | GraphQL::Role::Nullable - GraphQL object role | ||
| 15 | |||
| 16 | =head1 SYNOPSIS | ||
| 17 | |||
| 18 | with qw(GraphQL::Role::Nullable); | ||
| 19 | |||
| 20 | # or runtime | ||
| 21 | Role::Tiny->apply_roles_to_object($foo, qw(GraphQL::Role::Nullable)); | ||
| 22 | |||
| 23 | =head1 DESCRIPTION | ||
| 24 | |||
| 25 | Allows type constraints for nullable objects. | ||
| 26 | |||
| 27 | =head1 METHODS | ||
| 28 | |||
| 29 | =head2 non_null | ||
| 30 | |||
| 31 | Returns a wrapped version of the type using L<GraphQL::Type::NonNull>, | ||
| 32 | i.e. that may not be null. | ||
| 33 | |||
| 34 | =cut | ||
| 35 | |||
| 36 | has non_null => ( | ||
| 37 | is => 'lazy', | ||
| 38 | isa => InstanceOf['GraphQL::Type::NonNull'], | ||
| 39 | 96 | ▶ | builder => sub { GraphQL::Type::NonNull->new(of => $_[0]) }, |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
_build_non_null: called CC=1 SCAR=0.0
| |||
| 40 | 8 | ); | |
| 41 | |||
| 42 | 8 | __PACKAGE__->meta->make_immutable(); | |
| 43 | |||
| 44 | 8 | 1; | |