Skip to content

v9.0.0

Compare
Choose a tag to compare
@github-actions github-actions released this 30 Sep 21:42
· 69 commits to master since this release
0030927

9.0.0 (2020-09-30)

You can find detailed Release Notes on this page.

Code Refactoring

  • refactor pagination & connection resolvers. Now they are using count & findMany resolver instances instead of getting them by string-name. Move them from peerDependencies to dependencies. (f67a39f)
  • updateById: pull out _id arg from record. It was an old schema design error. (84574b7)
  • get rid of getRecordIdFn(); add test helper functions testOperation() & testFieldConfig() (7e3de3d), closes #262

Features

  • add {sort: { multi: true }} option to resolvers which have sort arg. This option makes sort arg as List where the client can provide several sorting keys. (0f5e435), closes #210
  • add defaultsAsNonNull options to composeMongoose method which makes all fields with default values as NonNull in GraphQL Schema (1cedd33), closes #261
  • add payload.error field to all mutation resolvers. If client request error field then typed error will be returned in mutation payload, otherwise it will be on top-level errors field. (bafc03f)
  • add RegExpAsString GraphQL custom scalar type for filtration by RegExp (2a399aa)
  • add suffix option to resolvers which may generate different sub-types according to config. It allows to avoid Type name collision if you generate several resolvers from one with different configs. (730c062), closes #268
  • add new resolvers dataLoader, dataLoaderMany. These resolvers are quite helpful for relations construction between Entities for avoiding the N+1 Problem. (05a3355)
  • add support for custom _id in models. Before it was only MongoID. Now it can be of any type (Int, String, Object). (d4f6cee), closes #141
  • added new function composeMongoose which generates TypeComposer without resolvers. Now Resolvers can be generated on-demand in such way PostTC.mongooseResolvers.findMany() (before was PostTC.getResolver('findMany')). (f36e276), closes #263
  • customization option resolvers.*.filter.operators now accept true value, it enables operators for all fields in resolver filter (by default operators added only for indexed fields). Also change generated typenames for Operators' types. (5004b1d)
  • expose resolverFactory for manual resolver creation, eg. for cloned types: resolverFactory.findMany(UserModel, ClonedUserTC, opts) – it generates Resolver's types according to ClonedUserTC type and will use mongoose UserModel for making requests to DB (b62ef6f)
  • improve return types for findByIds & findMany now they returns empty array instead of null (ad6ed68)
  • improve typescript definitions (0ac071d)
  • nested aliases are now supported for filter, projection & lean (d27f79a)
  • resolvers: now resolvers have typechecks for args param (it checks names and presence of required arguments) (1a54aaf)

BREAKING CHANGES

  • remove default export from package. Use import { composeMongoose } from 'graphql-compose-mongoose';
  • if you use ObjectTypeComposer.setRecordIdFn() for customization recordId in mutations payload then you will need use resolvers config options, eg. createOne(model, tc, { recordIdFn: (doc, context) => source.uid }).
  • updateById: resolver updateById changes its arguments. Before was updateById(record: { _id: 1, name: 'New' }), now became updateById(_id: 1, record: { name: 'New' })
  • some internal filter type names for args were changed. It may break some clients if you use that type names in your graphql queries:
  • count resolver change name for filter type Filter*Input -> FilterCount*Input