Repository navigation
Releases
Releases · robertz/bx-graphql
0.3.0
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()namedlimitandoffsetbecomeIntarguments of the list field. - Two classes under
servicePathswith the name a@graphqlCrudgives fail at construction time.
Safer in front of untrusted clients
- Query limits —
maxQueryDepthandmaxQueryComplexityrefuse an oversized query before any resolver runs. - Introspection toggle —
introspection : falserefuses__schemaand__type. - Error masking —
maskErrors : truetells clientsInternal server errorwhen a resolver throws; a function decides which messages pass.onErrorstill receives the real exception. - Guards on properties and hand-written resolvers —
@graphqlRequiresnow works on a bean's properties and on methods of{Type}Resolver.bxclasses.
Also new
operationName— a fourth argument toexecute(), 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 inerrors.
Changed
@graphqlRequireson a bean's class now covers its properties as well as its@graphqlFieldfunctions.- The app's context travels in graphql-java's
GraphQLContext. Thecontextargument is unchanged, butenv.getContext()no longer returns it: use the argument, orenv.getGraphQlContext().get( "bxgraphql.context" ).
Housekeeping
- MIT
LICENSEfile, and a GitHub Actions workflow that runs the specs on every push and pull request.
0.2.0
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.