GraphQ...::Test(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

πŸ’– NAME πŸ’–

Okay bestie, welcome to GraphQ...::Test(3pm) β€” that's the page title, and she lives in the User Contributed Perl Documentation section, so you know she's community-made and community-loved. 🫢

GraphQL::Plugin::Convert::Test β€” literally just a GraphQL plugin test class. That's the whole vibe. ✨


πŸŽ€ SYNOPSIS πŸŽ€

Here's the tea, copy it exactly, don't freestyle:

package main;
use GraphQL::Plugin::Convert::Test;
use GraphQL::Execution qw(execute);
my $converted = GraphQL::Plugin::Convert::Test->to_graphql;
print execute(
  $converted->{schema}, '{helloWorld}', $converted->{root_value}
)->{data}{helloWorld}, "\n";

# show schema from shell
perl -Maliased=GraphQL::Plugin::Convert::Test -e 'print Test->to_graphql->{schema}->to_doc'

🌸 DESCRIPTION 🌸

It's an example class. Its whole job? Letting you test convert plugin consumers. That's it, that's the mission. Lowkey iconic for how unbothered it is. πŸ’…


πŸ‘‘ METHODS πŸ‘‘

So what does she actually do? She produces a schema and a root value, and together they define a top-level query field called helloWorld. Ask for it and you get the string "Hello, world!" back. Simple. Clean. Gorgeous. 🌈

She also ships a mutation called echo that takes a String s, and β€” you guessed it β€” returns it. Echo does what echo says. No notes. πŸ”₯

πŸ¦‹ to_graphql(@values) πŸ¦‹

Here's the important part, so listen up:

If the first value is true, then that value is a subscribe_resolver, and that turns subscriptions on in the generated schema. It'll come back to you as the relevant key in the hash-ref, which is exactly what you want, because that's the shape you pass as the relevant arg to subscribe in GraphQL::Subscription. Chef's kiss. 😭

And then the schema gets a subscription field named timedEcho that takes a String s, and it should return that s periodically β€” the timing is entirely determined by the subscription function, so that part is on you, bestie. Not me. 🧚

fr fr: timedEcho returning "periodically" is the described intent β€” the actual cadence comes from whatever subscription function you hand it.

Sign-off time, my love: this page is perl v5.34.0, dated 2022-03-27. Go write something slay. πŸ’–βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from