GraphQ...ective(3pm)
π GraphQL::Directive β the directive glow-up π
okay bestie so this is a GraphQL directive, from the User Contributed Perl Documentation collection, and yes it's giving exactly what you think it's giving. a directive. a whole directive. iconic behavior honestly π
β¨ NAME β¨
GraphQL::Directive β a GraphQL directive. that's it. that's the name. short, sweet, slays. π
πΈ SYNOPSIS πΈ
here's the vibe, copy-paste it, it's yours now:
use GraphQL::Directive;
my $directive = GraphQL::Directive->new(
name => 'Object',
interfaces => [ $interfaceType ],
fields => { field_name => { type => $scalar_type, resolve => sub { '' } }},
);
literally just construct one and go. no cap. π¦
π ATTRIBUTES π
so it's got name and description, and those two are inherited from GraphQL::Role::Named β it didn't even have to work for those, it got them from the role. main character energy fr fr. β¨
π locations
this one's an array-ref of all the locations where the directive is allowed to show up. and it's strict, bestie β it must be one of these exact strings, no improvising:
QUERY
MUTATION
SUBSCRIPTION
FIELD
FRAGMENT_DEFINITION
FRAGMENT_SPREAD
INLINE_FRAGMENT
SCHEMA
SCALAR
OBJECT
FIELD_DEFINITION
ARGUMENT_DEFINITION
INTERFACE
UNION
ENUM
ENUM_VALUE
INPUT_OBJECT
INPUT_FIELD_DEFINITION
eighteen of them. count them. I did. π§
π args
a hash-ref of arguments. if you wanna know the shape of that, go look at "FieldMapInput" in GraphQL::Type::Library β they explain it, I'm just the messenger. π
π₯ METHODS π₯
π¦ from_ast
see "from_ast" in GraphQL::Type. that's where the real tea is. π
β PACKAGE VARIABLES β
π $GraphQL::Directive::DEPRECATED
π $GraphQL::Directive::INCLUDE
π $GraphQL::Directive::SKIP
π @GraphQL::Directive::SPECIFIED_DIRECTIVES
okay so these are not exported β you have to reach for them by full name, they're not gonna come to you, you gotta go to them. π
@GraphQL::Directive::SPECIFIED_DIRECTIVES holds the three GraphQL-specified directives: @skip, @include, and @deprecated. each one of those is available through the individual variables above. π
use it when you want those three plus your own little custom directives chillin' in your schema together:
my $schema = GraphQL::Schema->new(
# ...
directives => [ @GraphQL::Directive::SPECIFIED_DIRECTIVES, $my_directive ],
);
see? specified ones first, then $my_directive doing its own thing at the end. they coexist. we love a collaborative moment. π«Ά
ngl that's the whole page. every attribute, every location string, every variable, all accounted for. nothing skipped, nothing summarised, we ate and left no crumbs. π
and that's a wrap on GraphQL::Directive(3pm) β brought to you by perl v5.34.0, dated 2022-03-27, part of the User Contributed Perl Documentation. stay hydrated, read your docs, bye bestie πβ¨π
π¦ 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