GraphQ...onvert(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::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 β€” a GraphQL::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_value by "execute" in GraphQL::Execution. Optional.
  • subscribe_resolver β€” a code-ref that's suitable for using as a $subscribe_resolver by "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