Project
bx-graphql
A schema-agnostic GraphQL server for native BoxLang, wrapping graphql-java (vendored, v26.0). Write .graphqls files, annotate the classes you already have, or both; it hands back a plain {data, errors} struct. No ColdBox, no WireBox, no HTTP framework required. It's the pure-BoxLang sibling to coldbox-graphql.
Schema-first
Point schemaPaths at a directory of .graphqls files. A resolver class is only needed for fields with logic; the rest are read off a struct or a class instance.
Code-first
Mark beans @graphqlType and service functions @graphqlQuery or @graphqlMutation. The schema is generated and each field is wired straight to its method; @graphqlCrud adds get, list, save and delete.
Built for real APIs
@graphqlRequires authorization, depth and complexity limits, error masking, batch loaders for N+1 lookups, custom scalars, interfaces and unions.
Zero framework
A global bxGraphQL() BIF, registered when the module loads. execute() never touches HTTP, so POST /graphql belongs to whatever router your app uses.
bashbox install bx-graphql
bxsgraphQLService = bxGraphQL( {
"schemaPaths" : [ expandPath( "/graphql/schema" ) ],
"resolverBasePackage" : "models.resolvers"
} )
result = graphQLService.execute(
query = '{ widget(id: "1") { name } }',
queryVariables = {},
context = ""
)
// result == { "data" : { "widget" : { "name" : "..." } }, "errors" : [] }
Or generate the schema from annotated classes, with no .graphqls files at all:
bxsgraphQLService = bxGraphQL( {
"modelPaths" : [ expandPath( "models/beans" ) ],
"servicePaths" : [ expandPath( "models/services" ) ]
} )