GraphQL::Type(3pm)
π GraphQL::Type π
okay bestie, welcome to the GraphQL::Type page β it's a Perl module (that's the 3pm vibe, iykyk), and it is literally the blueprint era of the GraphQL type world. sit down, grab a strawberry drink π, and let's get into it.
β¨ SYNOPSIS β¨
like, this is the whole move:
extends qw(GraphQL::Type);
that's it. that's the post. π
πΈ DESCRIPTION πΈ
so this is the superclass for all the other GraphQL type classes to inherit from. it's giving mother of the family, main character energy, the one everyone else extends. π
π¦ ENCODING π¦
okay so every one of these Perl classes implements a GraphQL type, right? and every single item of GraphQL data has a GraphQL type. and plot twist β that same piece of data can also exist inside Perl. so objects of that Perl class are the ones holding it down and translating back and forth between the Perl representation and the "GraphQL representation".
and what even is a "GraphQL representation", you ask? it means something that's JSON-encodeable: an "object" (in Perl terms, a hash), an array (Perl: array-reference), a string, a number, a boolean, or null. the whole roster. π
peep "METHODS" down below for the generic methods that do the back-and-forth between these two worlds.
β οΈ real talk though β the code you provide for this translation has to return things that can be JSON-encoded, not things that have already been encoded. which means, among other things: do not wrap your strings in"", and for boolean values use the mechanism inJSON::MaybeXS:JSON-"true>etc. don't do the encoding yourself, bestie, that's not your job. π
π SUBCLASSES π
these subclasses implement part of the GraphQL language specification. objects of these classes implement user-defined types, which is what you use to actually build a GraphQL API. iconic behavior. β¨
GraphQL::Type::EnumGraphQL::Type::InputObjectGraphQL::Type::InterfaceGraphQL::Type::ListGraphQL::Type::NonNullGraphQL::Type::ObjectGraphQL::Type::Scalarβ also implements example types such as"String"GraphQL::Type::Union
π§ ROLES π§
and these roles implement part of the GraphQL language specification too. they get applied to objects of GraphQL::Type classes β either to facilitate type constraints, or as noted below. slay. π«Ά
GraphQL::Role::FieldsInputβ providesfieldsattribute for an input typeGraphQL::Role::FieldsOutputβ providesfieldsattribute for an output typeGraphQL::Role::Abstractβ abstract typeGraphQL::Role::Compositeβ type has fieldsGraphQL::Role::Inputβ type can be an inputGraphQL::Role::Leafβ simple type β enum or scalarGraphQL::Role::Listableβ can be list-wrapped; provides convenience methodGraphQL::Role::Namedβ has anameanddescription, provided by this roleGraphQL::Role::Nullableβ can be null-valuedGraphQL::Role::Outputβ type can be an output
π TYPE LIBRARY π
GraphQL::Type::Libraryβ implements variousType::Tinytype constraints, for use in Moo attributes, andFunction::Parameters/Return::Typemethods and functions. very demure, very mindful. π
π METHODS π
π uplift
turn given Perl entity into a valid Perl value for this type, if possible. no promises if it's not possible, bestie. π
π graphql_to_perl
turn given GraphQL entity into a Perl entity. the glow-up, but in reverse. π₯
π perl_to_graphql
turn given Perl entity into a GraphQL entity. the glow-up. π₯
π from_ast($name2type, $ast_node)
class method, okay? so $name2type is a hash-ref populated by "from_ast" in GraphQL::Schema. it takes a hash-ref node from an AST made by "parse" in GraphQL::Language::Parser. returns a type object. that's the whole quest. β
π to_doc($doc)
returns a Schema Definition Language (SDL) document that describes this object. it's giving author era, it's giving documentation queen. πβ¨
and that's the page, bestie!! π¦ this whole thing came to you courtesy of perl v5.34.0, dated 2022-03-27, and yeah it's the GraphQL::Type(3pm) page β go forth and type responsibly, ily, mwah ππ
π¦ where this page comes from
- debian bookworm: libgraphql-perl 0.54-1 Β· Artistic-2.0
- debian trixie: libgraphql-perl 0.54-1 Β· Artistic-2.0
- ubuntu noble: libgraphql-perl 0.54-1 Β· Artistic-2.0
- ubuntu resolute: libgraphql-perl 0.54-1 Β· Artistic-2.0
- ubuntu stonking: libgraphql-perl 0.54-1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms