bx-graphql 0.2.0
Released .
Code-first schema
Annotate the classes you already have instead of (or as well as) writing .graphqls files and resolver classes. See Code-first schema in the README.
- Types and inputs from beans —
modelPaths: classes marked@graphqlType/@graphqlInput, a field per property, doc comments as descriptions.@graphqlId,@graphqlField,@graphqlInputField,@graphqlReadOnly,@graphqlWriteOnly,@graphqlIgnore,@graphqlDeprecated. - Queries and mutations from services —
servicePaths: public functions marked@graphqlQuery/@graphqlMutation, wired straight to the method. Input arguments arrive as populated beans;context,envandargsparameters are injected. - Functions as fields —
@graphqlFieldon a bean's function. - Enums —
@graphqlEnum( "A, B, C" ). - Interfaces and unions — written in SDL, joined with
@graphqlImplements; the concrete type comes fromresolveType(),__typename, or the bean's class. - Authorization —
@graphqlRequires( "what" )with anauthorizersetting. - Batch loading — a
loaderssetting backed by graphql-java's DataLoader. getGeneratedSDL()andprintSchema().
Also new
- Custom scalars — a
scalarssetting, withDateTimeandLongbuilt in. - Structured errors —
structuredErrors : truegives{ message, path, locations, extensions };onErrorreceives each error with its exception. instanceFactory— build services, resolvers and input beans through your own DI.
Changed
- A resolver that returns a class instance now has its fields read through getters and public members. They used to come back null, without an error.
- Resolver
argshold the values as graphql-java coerced them, no longer passed through a JSON round trip. schemaPathsandresolverBasePackageare optional oncemodelPathsorservicePathsis set. Without those, both are required as before.
Schema-first apps need no changes. Developed and tested on BoxLang 1.19.0.