GraphQ...onvert(3pm)
π GraphQL::Plugin::Convert β the abstract bestie π
okay so this is GraphQL::Plugin::Convert(3pm), straight out of the User Contributed Perl Documentation, and it's an abstract class β the blueprint, the vibe, the template. It's the GraphQL plugin API, and honestly? she's giving β¨framework energyβ¨.
πΈ NAME πΈ
GraphQL::Plugin::Convert β the GraphQL plugin API abstract class π«Ά
π¦ SYNOPSIS π¦
like, here's how you'd actually use her:
package GraphQL::Plugin::Convert::DBIC;
use Moo;
extends qw(GraphQL::Plugin::Convert);
# ...
package main;
use Mojolicious::Lite;
use Schema;
use GraphQL::Plugin::Convert::DBIC;
helper db => sub { Schema->connect('dbi:SQLite:test.db') };
my $converted = GraphQL::Plugin::Convert::DBIC->to_graphql(sub { app->db });
plugin GraphQL => {
map { $_ => $converted->{$_} }
qw(schema resolver root_value subscribe_resolver)
};
# OR, for knowledgeable consumers of GraphQL::Plugin::Convert APIs:
package main;
use Mojolicious::Lite;
use Schema;
helper db => sub { Schema->connect('dbi:SQLite:test.db') };
plugin GraphQL => { convert => [ 'DBIC', sub { app->db } ] };
no cap, that second block is for the knowledgeable consumers of GraphQL::Plugin::Convert APIs β iykyk π
π DESCRIPTION π
She's an abstract class for other GraphQL type classes to inherit from and implement. That's the whole job. She doesn't do the thing herself β she's the vibe, the contract, the main character that everyone else extends. π
π METHODS π
β to_graphql(@values)
When you call her with suitable values (and "suitable" is defined by whichever class is implementing her, so like, ask them), she hands you back a hash-ref with these keys:
schemaβ aGraphQL::Schema. π¦resolverβ a code-ref that's suitable for using as a resolver by"execute" in GraphQL::Execution. Optional.root_valueβ a hash-ref that's suitable for using as a$root_valueby"execute" in GraphQL::Execution. Optional.subscribe_resolverβ a code-ref that's suitable for using as a$subscribe_resolverby"subscribe" in GraphQL::Subscription. Optional.
π from_graphql
Call her with a hash-ref shaped like the one above β as long as it has at least a "schema" key holding a GraphQL::Schema β and she returns some value(s). π«Ά
This one's optional to implement. But if your plugin does implement it? Iconic. That's what unlocks conversion from a GraphQL schema to that plugin's domain. periodt. π β¨
lowkey important reminder bestie: she's abstract. You don't use her directly, you extend her and implement the stuff. That's the whole assignment. π
and that's the page!! authored into the User Contributed Perl Documentation, running on perl v5.34.0, dated 2022-03-27 β shoutout to that whole era of the docs, she ate and left no crumbs ππΈπ¦ mwah, bye!!
π¦ 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