DBIO-GraphQL
Auto-generate a GraphQL schema from a DBIO schema.
DBIO::GraphQL->to_graphql($schema) introspects every source registered with a
connected DBIO::Schema and returns an executable GraphQL::Schema with:
- One scalar field per column, typed from the column's
data_type(Booleanforbool*/tinyint(1),Floatfordecimal/numeric/...,Intfor the rest of the integer family,Stringotherwise). - One relationship field per DBIO relationship (
has_many→ list,belongs_to/might_have→ single object). Build-time errors are emitted when the DBIOrelationship_infocontract is incomplete. - A root
Querytype with singular lookups and pluralallXsqueries supporting nested per-column filtering, ordering, and offset/cursor pagination. - A root
Mutationtype withcreateX,updateX,deleteXper source.
Composite primary keys are supported throughout.
Synopsis
use DBIO::GraphQL;
use GraphQL::Execution qw(execute);
my $db = My::Schema->connect(...);
my $result = DBIO::GraphQL->to_graphql($db);
# Plural query with nested-DBIO-style filter
execute($result->{schema}, '
query {
allBooks(
filter: { title: { like: "%Perl%" } }
orderBy: { field: "title", direction: ASC }
page: { skip: 0, take: 5 }
) {
total nodes { id title }
}
}', undef, $result->{context});
See the module POD (perldoc DBIO::GraphQL) for the full query/mutation
surface, filtering operators, pagination, limitations, and known behaviour.
Architecture
DBIO::GraphQL is a thin orchestrator over four focused modules:
DBIO::GraphQL::ScalarMap- columndata_type→ GraphQL scalarDBIO::GraphQL::Filter(and::Search,::Nulladapters) - per-source GraphQLInputObjecttranslating nested filter args into DBIO search conditionsDBIO::GraphQL::Relationship- relationship field resolution with strict contract validation (closes KARR #1)DBIO::GraphQL::Mutation-createX/updateX/deleteXper source
Each module is independently testable through its own public interface.
Acknowledgements
DBIO port of
DBIx::Class::Schema::GraphQL
by Mohammad Sajid Anwar (MANWAR). The original DBIx::Class implementation,
design, and documentation are his work; this distribution adapts them to the
DBIO schema introspection API and re-architects the filter surface into
a nested per-column shape that mirrors DBIO's native search-condition format.