GraphQ...ective(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

πŸ’– 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