Skip to content

0.2.0

Choose a tag to compare

@robertz robertz released this 26 Nov 15:41
· 4 commits to main since this release

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, env and args parameters are injected.
  • Functions as fields — @graphqlField on a bean's function.
  • Enums — @graphqlEnum( "A, B, C" ).
  • Interfaces and unions — written in SDL, joined with @graphqlImplements; the concrete type comes from resolveType(), __typename, or the bean's class.
  • Authorization — @graphqlRequires( "what" ) with an authorizer setting.
  • Batch loading — a loaders setting backed by graphql-java's DataLoader.
  • getGeneratedSDL() and printSchema().

Also new

  • Custom scalars — a scalars setting, with DateTime and Long built in.
  • Structured errors — structuredErrors : true gives { message, path, locations, extensions }; onError receives 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 args hold the values as graphql-java coerced them, no longer passed through a JSON round trip.
  • schemaPaths and resolverBasePackage are optional once modelPaths or servicePaths is set. Without those, both are required as before.

Schema-first apps need no changes. Developed and tested on BoxLang 1.19.0.