Skip to content

Releases

0.3.0

Choose a tag to compare

@robertz robertz released this 28 Nov 17:13

CRUD from a bean

@graphqlCrud( "WidgetService" ) on a bean generates a field for each of get, list, save and delete that service has: widget( id ), widgets, saveWidget( input ) and deleteWidget( id ). @graphqlCrudNames( "list=people" ) renames them. See CRUD from a bean in the README.

  • Paging — parameters of the service's list() named limit and offset become Int arguments of the list field.
  • Two classes under servicePaths with the name a @graphqlCrud gives fail at construction time.

Safer in front of untrusted clients

  • Query limits — maxQueryDepth and maxQueryComplexity refuse an oversized query before any resolver runs.
  • Introspection toggle — introspection : false refuses __schema and __type.
  • Error masking — maskErrors : true tells clients Internal server error when a resolver throws; a function decides which messages pass. onError still receives the real exception.
  • Guards on properties and hand-written resolvers — @graphqlRequires now works on a bean's properties and on methods of {Type}Resolver.bx classes.

Also new

  • operationName — a fourth argument to execute(), for a document holding several operations.
  • handle( body, context ) — runs a GraphQL-over-HTTP request body, as a struct or JSON text; a body that can't be run comes back as an entry in errors.

Changed

  • @graphqlRequires on a bean's class now covers its properties as well as its @graphqlField functions.
  • The app's context travels in graphql-java's GraphQLContext. The context argument is unchanged, but env.getContext() no longer returns it: use the argument, or env.getGraphQlContext().get( "bxgraphql.context" ).

Housekeeping

  • MIT LICENSE file, and a GitHub Actions workflow that runs the specs on every push and pull request.

0.2.0

Choose a tag to compare

@robertz robertz released this 26 Nov 15:41

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.