Scroll to navigation

GraphQL::MaybeTypeCheck(3pm) User Contributed Perl Documentation GraphQL::MaybeTypeCheck(3pm)

NAME

GraphQL::MaybeTypeCheck - Conditional type-checking at runtime

SYNOPSIS

  use GraphQL::MaybeTypeCheck;
  method foo(
    $arg1 Str,
    $arg2 Int
  ) :ReturnType(Map[Str, Int]) {
    # ...
  }

DESCRIPTION

This module optionally enables type-checking in the caller as implemented by Function::Parameters and Return::Type depending on whether Devel::StrictMode is activated.

"Devel::StrictMode" ON

When Devel::StrictMode is active, this module will import Function::Parameters into the caller with its default configuration. As of writing, this includes checking both argument count and type.

When in strict mode this also "require"s Return::Type which registers the "ReturnType" attribute.

"Devel::StrictMode" OFF

When strict mode is inactive this module still imports "Function::Parameters" into the caller however it sets "fun" and "method" to lax mode and disables argument type checking.

This also installs a no-op "ReturnType" attribute so the existing syntax isn't broken.

2022-03-27 perl v5.34.0