GraphQ...:Scalar(3pm)

πŸ“¦
version 0.54 Β· 2 versions
  • 0.54 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.53 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’… NAME πŸ’…

GraphQL::Type::Scalar β€” it's giving GraphQL scalar type, bestie ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

okay so here's the vibe, literally just:

use GraphQL::Type::Scalar;
my $int_type = GraphQL::Type::Scalar->new(
  name => 'Int',
  description =>
    'The `Int` scalar type represents non-fractional signed whole numeric ' .
    'values. Int can represent values between -(2^31) and 2^31 - 1. ',
  serialize => \&coerce_int,
  parse_value => \&coerce_int,
);

no cap, that's the whole thing 🌸


πŸŽ€ ATTRIBUTES πŸŽ€

It's got name and description, and those two are coming straight from GraphQL::Role::Named πŸ’œ

✨ serialize

Code-ref. Required. not optional, not "maybe later", it's required fr fr πŸ’€

It coerces from a Perl entity of the required type over to a GraphQL entity β€” or it throws an exception. Those are the options.

bestie listen: it must throw an exception if you pass it a defined (i.e. non-null) but invalid Perl object of the relevant type. That's non-negotiable. But undef? undef must always be valid. always always. 🫢

🌈 parse_value

Code-ref. Required if it's for an input type πŸ”₯

It coerces from a GraphQL entity to a Perl entity of the required type β€” or, you guessed it, throws an exception. πŸ‘‘


⭐ METHODS ⭐

🌸 is_valid

True if the given Perl entity is a valid value for this type. It's using the serialize attribute under the hood, iykyk πŸ’…


πŸ‘‘ EXPORTED VARIABLES πŸ‘‘

Here's the squad, they come exported:

  • $Int
  • $Float
  • $String
  • $Boolean
  • $ID

iconic lineup honestly πŸŽ€βœ¨


that's the whole page bestie, slay πŸ’– this was User Contributed Perl Documentation, running on perl v5.34.0, dated 2022-03-27 β€” periodt πŸŒΈπŸ¦‹

πŸ“¦ where this page comes from