---
name: "GraphQL::Type::Scalar"
section: "3pm"
platform: "linux"
package: "libgraphql-perl"
version: "0.54-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/GraphQL::Type::Scalar"
---

# GraphQL::Type::Scalar(3pm)

GraphQL scalar type

## NAME

GraphQL::Type::Scalar - GraphQL scalar type

## SYNOPSIS

```
  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,
  );
```

## ATTRIBUTES

Has `"name"`, `"description"` from GraphQL::Role::Named.

### serialize

Code-ref. Required.

Coerces **from** a Perl entity of the required type, **to** a GraphQL entity, or throws an exception.

Must throw an exception if passed a defined (i.e. non-null) but invalid Perl object of the relevant type. `"undef"` must always be valid.

### parse\_value

Code-ref. Required if is for an input type.

Coerces **from** a GraphQL entity, **to** a Perl entity of the required type, or throws an exception.

## METHODS

### is\_valid

True if given Perl entity is valid value for this type. Uses "serialize" attribute.

## EXPORTED VARIABLES

### $Int

### $Float

### $String

### $Boolean

### $ID
